/// <summary> /// Creates user based on params /// </summary> /// <param name="value"></param> /// <returns></returns> public UserModel Create(UserModel value) { var result = CrudRepository.Create(new Users() { Id = Guid.NewGuid(), Name = value.Name, UserName = value.UserName, IsAnonymous = value.IsAnonymous }); value.Id = result.Id; // Created item return value; }
/// <summary> /// Deletes user based on params /// </summary> /// <param name="model"></param> /// <returns></returns> public UserModel Delete(UserModel model) { var result = CrudRepository.Delete(model.Id); if (result != null) { model.Name = result.Name; model.UserName = result.UserName; model.IsAnonymous = result.IsAnonymous; } return model; }
/// <summary> /// The put request /// </summary> /// <param name="id"></param> /// <param name="model"></param> /// <returns></returns> public UserModel Put(string id, UserModel model) { return repository_.Update(Guid.Parse(id), model); }
/// <summary> /// Updates user based on params /// </summary> /// <param name="id"></param> /// <param name="value"></param> /// <returns></returns> public UserModel Update(Guid id, UserModel value) { var result = CrudRepository.Update(id, new Users() { Id = value.Id, Name = value.Name, UserName = value.UserName, IsAnonymous = value.IsAnonymous }); value.Id = id; return value; }
/// <summary> /// The post request /// </summary> /// <param name="model"></param> /// <returns></returns> public UserModel Post(UserModel model) { return repository_.Create(model); }