Exemple #1
0
        public async Task <SharedLookUpResponse> AddComponentAsync(AddBedStatus addComponent, int instituteId)
        {
            if (!await iMSDbContext.BedStatuses.AnyAsync(x => x.InstituteId == instituteId && x.Name.ToLowerInvariant() == addComponent.Name.ToLowerInvariant()))
            {
                var componentGroup = new BedStatus()
                {
                    CreatedOn   = DateTime.UtcNow,
                    InstituteId = instituteId,
                    Name        = addComponent.Name,
                };
                iMSDbContext.BedStatuses.Add(componentGroup);
                await iMSDbContext.SaveChangesAsync();

                return(new SharedLookUpResponse()
                {
                    HasError = false, Message = "Bed Status added successfully"
                });
            }
            else
            {
                return(new SharedLookUpResponse()
                {
                    HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Component group with same code is already existed"
                });
            }
        }
Exemple #2
0
 public async Task <IActionResult> AddGroupAsync([FromBody] AddBedStatus addGroupAc)
 {
     if (string.IsNullOrEmpty(addGroupAc.Name.Trim()))
     {
         return(Ok(new SharedLookUpResponse()
         {
             HasError = true,
             ErrorType = SharedLookUpResponseType.Name,
             Message = "Bed Status name can't be null or empty"
         }));
     }
     else
     {
         return(Ok(await bedStatusManagement.AddComponentAsync(addGroupAc, await GetUserCurrentSelectedInstituteIdAsync())));
     }
 }