Beispiel #1
0
        private Lab GetLab(CorporateCustomerEditModel model, OrganizationRoleUser createdByOrgRoleUser, IEnumerable <Lab> labs)
        {
            Lab lab = null;

            if (!string.IsNullOrEmpty(model.Lab))
            {
                lab = labs.FirstOrDefault(l => l.Name.Trim().ToLower() == model.Lab.Trim().ToLower());
                if (lab == null)
                {
                    lab = _labRepository.GetByName(model.Lab);
                    if (lab == null)
                    {
                        lab = new Lab
                        {
                            Name     = model.Lab,
                            Alias    = model.Lab,
                            IsActive = true,
                            CreatedByOrgRoleUserId = createdByOrgRoleUser.Id,
                            DateCreated            = DateTime.Now
                        };

                        lab = _labRepository.Save(lab);
                    }
                }
            }

            return(lab);
        }
Beispiel #2
0
        public async Task <object> PostLabModel(LabInputModel labModel)
        {
            object result;

            if (await _labRepository.GetByName(labModel.Name) == null)
            {
                result = await _labRepository.Add(labModel);
            }
            else
            {
                result = "bad request";
            }

            if (result.Equals("bad request"))
            {
                return(BadRequest());
            }
            else
            {
                return(result);
            }
        }