Ejemplo n.º 1
0
        public async Task <SharedLookUpResponse> AddComponentAsync(AddComponentAc addComponent, int instituteId)
        {
            if (!await iMSDbContext.PayrollComponents.AnyAsync(x => x.InstituteId == instituteId && x.Name.ToLowerInvariant() == addComponent.Name.ToLowerInvariant()))
            {
                var component = new PayrollComponent()
                {
                    CreatedOn   = DateTime.UtcNow,
                    InstituteId = instituteId,
                    Name        = addComponent.Name,
                    ShortName   = addComponent.ShortName,
                    SequenceNo  = addComponent.SequenceNo,
                    GroupId     = addComponent.GroupId,
                    IsPayslip   = addComponent.IsPayslip,
                    IsBasic     = addComponent.IsBasic,
                    Others      = addComponent.Others,
                    Description = addComponent.Description,
                    Status      = addComponent.Status
                };
                iMSDbContext.PayrollComponents.Add(component);
                await iMSDbContext.SaveChangesAsync();

                return(new SharedLookUpResponse()
                {
                    HasError = false, Message = "Component Group added successfully"
                });
            }
            else
            {
                return(new SharedLookUpResponse()
                {
                    HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Component with same Name is already existed"
                });
            }
        }
Ejemplo n.º 2
0
 public async Task <IActionResult> AddComponentAsync([FromBody] AddComponentAc addComponentAc)
 {
     if (string.IsNullOrEmpty(addComponentAc.Name.Trim()))
     {
         return(Ok(new SharedLookUpResponse()
         {
             HasError = true,
             ErrorType = SharedLookUpResponseType.Name,
             Message = "Component Group name can't be null or empty"
         }));
     }
     else if (string.IsNullOrEmpty(addComponentAc.ShortName.Trim()))
     {
         return(Ok(new SharedLookUpResponse()
         {
             HasError = true,
             ErrorType = SharedLookUpResponseType.Name,
             Message = "Component Group code can't be null or empty"
         }));
     }
     else
     {
         return(Ok(await componentManagementRepository.AddComponentAsync(addComponentAc, await GetUserCurrentSelectedInstituteIdAsync())));
     }
 }