Example #1
0
        public async Task <int> Add(UserType userType)
        {
            userTypeRepository.Add(userType);
            var res = await userTypeRepository.Save();

            return(res);
        }
Example #2
0
        public async Task <UserTypeModel> Add(UpsertUserTypeModel model)
        {
            var userType = new UserType(model.Name, model.Description);

            await repository.Add(userType);

            await repository.SaveChanges();

            return(mapper.Map <UserTypeModel>(userType));
        }
        public async Task <UserType> Add(UserType type)
        {
            if (_userTypeRepository
                .Search(b => b.Name.ToLower() == type.Name.ToLower())
                .Result.Any())
            {
                return(null);
            }

            await _userTypeRepository.Add(type);

            return(type);
        }
Example #4
0
        public JsonResult Save([FromBody] UserType userType)
        {
            var result = new UserType();

            if (userType.Id > 0)
            {
                result = UserTypeRepository.Update(userType);
            }
            else
            {
                result = UserTypeRepository.Add(userType);
            }

            return(Json(result));
        }
Example #5
0
 public void Add(UserType userType)
 {
     try
     {
         if (userTypes.GetAll().Where(x => x.TypeId == userType.TypeId).FirstOrDefault() == null)
         {
             if (userType != null)
             {
                 userTypes.Add(userType);
             }
         }
     }catch (Exception ex)
     {
         throw ex;
     }
 }
        public async Task <ActionResult <UserTypeViewModel> > PostUserType(UserTypeViewModel viewModel)
        {
            try
            {
                var entity = _mapper.Map <UserType>(viewModel);
                var model  = await _userTypeRepository.Add(entity);

                return(_mapper.Map <UserTypeViewModel>(model));
            }
            catch (InvalidDataException e)
            {
                return(BadRequest(new { message = e.Message }));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new { message = e.Message }));
            }
        }
Example #7
0
 public IUserType Add(UserType entity)
 {
     return(repository.Add(entity));
 }
 public void Insert(UserType entity)
 {
     _userTypeRepository.Add(entity);
 }