Commit e44cd7d2 authored by hasan khaddour's avatar hasan khaddour

Add Validation Behavior.

parent 9234a4d5
......@@ -10,8 +10,10 @@ using PSManagement.Application.Employees.UseCases.Commands.UpdateEmployeeWorkHou
using PSManagement.Application.Employees.UseCases.Queries.GetAvailableEmployees;
using PSManagement.Application.Employees.UseCases.Queries.GetEmployeeById;
using PSManagement.Application.Employees.UseCases.Queries.GetEmployeesByFilter;
using PSManagement.Application.Employees.UseCases.Queries.GetEmployeeTrackHistory;
using PSManagement.Contracts.Employees.Requests;
using PSManagement.Contracts.Projects.Response;
using PSManagement.Contracts.Tracks.Response;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -78,6 +80,17 @@ namespace PSManagement.Api.Controllers.Employees
return Ok(_mapper.Map<Result<IEnumerable<EmployeeParticipateResponse>>>(result));
}
[HttpPost("TrackHistory")]
public async Task<IActionResult> GetEmployeeTrackHistory([FromForm] GetEmployeeTrackHistoryRequest request)
{
var command = _mapper.Map<GetEmployeeTrackHistoryQuery>(request);
var result = await _sender.Send(command);
return Ok(_mapper.Map<Result<IEnumerable<EmployeeTrackResponse>>>(result));
}
[HttpPost("SyncEmployees")]
public async Task<IActionResult> Post()
......@@ -98,5 +111,6 @@ namespace PSManagement.Api.Controllers.Employees
return Ok(result);
}
}
}
using FluentValidation;
namespace PSManagement.Application.Customers.UseCases.Commands.AddContactInfo
{
public class AddContactInfoCommandValidator : AbstractValidator<AddContactInfoCommand>
{
public AddContactInfoCommandValidator()
{
RuleFor(x => x.ContactType)
.NotEmpty()
.MinimumLength(5);
RuleFor(x => x.ContactValue)
.MinimumLength(5);
}
}
}
......@@ -11,8 +11,11 @@ namespace PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
{
public CreateCustomerCommandValidator()
{
RuleFor(x => x.CustomerName).NotEmpty();
RuleFor(x => x.Email).EmailAddress();
RuleFor(x => x.CustomerName)
.NotEmpty()
.MinimumLength(5);
RuleFor(x => x.Email)
.EmailAddress();
}
}
}
using FluentValidation;
namespace PSManagement.Application.FinancialSpends.UseCases.Commands.CreateFinancialSpendItem
{
public class CreateFinancialSpendItemCommandValidator : AbstractValidator<CreateFinancialSpendItemCommand>
{
public CreateFinancialSpendItemCommandValidator()
{
RuleFor(x => x.Description)
.NotEmpty()
.MinimumLength(10);
RuleFor(x => x.ExternalPurchase.Ammount)
.GreaterThan(0);
RuleFor(x => x.ExternalPurchase.Currency)
.NotEmpty();
}
}
}
using FluentValidation;
namespace PSManagement.Application.Projects.UseCases.Commands.AddAttachment
{
public class AddAttachmentCommandValidator : AbstractValidator<AddAttachmentCommand>
{
public AddAttachmentCommandValidator()
{
RuleFor(x => x.AttachmentDescription)
.NotEmpty()
.MinimumLength(15);
RuleFor(x => x.AttachmentName)
.NotEmpty()
.MinimumLength(5);
}
}
}
......@@ -51,5 +51,4 @@ namespace PSManagement.Application.Projects.UseCases.Commands.AddProjectStep
}
}
}
}
using FluentValidation;
namespace PSManagement.Application.Projects.UseCases.Commands.AddProjectStep
{
public class AddProjectStepCommandValidator : AbstractValidator<AddProjectStepCommand>
{
public AddProjectStepCommandValidator()
{
RuleFor(x => x.Weight)
.GreaterThan(0)
.LessThan(101);
RuleFor(x => x.StepInfo.StartDate)
.GreaterThan(System.DateTime.Now);
RuleFor(x => x.StepInfo.Duration)
.GreaterThan(0);
RuleFor(x => x.StepInfo.Description)
.NotEmpty()
.MinimumLength(5);
RuleFor(x => x.StepInfo.StepName)
.NotEmpty()
.MinimumLength(5);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment