//public UserStatusProcessor(IUserStatusDao dao, IUserStatusParamConverter paramConverter, // IUserStatusResultConverter resultConverter) //{ // this.Dao = dao; // this.ParamConverter = paramConverter; // this.ResultConverter = resultConverter; //} public UserStatusResult Create(UserStatusParam param) { Model.UserStatus entity = ParamConverter.Convert(param, null); entity = Dao.Save(entity); return(ResultConverter.Convert(entity)); }
public void Update(long id, UserStatusParam param) { Model.UserStatus oldEntity = Dao.Find(id); if (oldEntity != null) { Dao.Delete(oldEntity); Dao.Update(ParamConverter.Convert(param, null)); } else { Console.WriteLine($"No entity with Id = {id} was found"); } }
public Response Create(UserStatusParam param) { Response response = new Response(); try { response.Text = "This entity has been added :" + Environment.NewLine + JsonConverter.JsonConverter.ObjToJson(Processor.Create(param)); response.Result = true; } catch { response.Text = "Unfortunately something went wrong. Are you sure that the entity you are trying to create doesn't already exist ?"; response.Result = false; } return(response); }
public Response Update(long id, UserStatusParam param) { Response response = new Response(); try { Processor.Update(id, param); response.Text = "The entity has been updated."; response.Result = true; } catch { response.Text = "The command was unable to execute. Are you sure the entity you want to update exists."; response.Result = false; } return(response); }
//public UserStatusService(IUserStatusProcessor processor) //{ // this.Processor = processor; //} /// <summary> /// Function to create new a entity . /// </summary> /// <param name="param">a entity</param> /// <returns>response and new entity</returns> public ApiResponse Create(UserStatusParam param) { ApiResponse response = new ApiResponse(); try { response.Text = $"The entity successfully added .\n" + $" {Serialization.Serizlize(Processor.Create(param))}"; response.Result = true; return(response); } catch (Exception ex) { response.Result = false; response.Text = ex.Message; return(response); } }
/// <summary> /// Function to update information about a entity . /// </summary> /// <param name="id">entity's id</param> /// <param name="param">entity</param> /// <returns>response and update entity</returns> public ApiResponse Update(long id, UserStatusParam param) { ApiResponse response = new ApiResponse(); try { Processor.Update(id, param); response.Text = "The entity updated successfully . \n"; response.Result = true; return(response); } catch (Exception ex) { response.Result = false; response.Text = ex.Message; return(response); } }
public Model.UserStatus Convert(UserStatusParam param, Model.UserStatus oldEntity) { Model.UserStatus entity = null; if (oldEntity != null) { entity = oldEntity; } else { entity = new Model.UserStatus() { Code = param.Code, Id = param.Id, Description = param.Description, Name = param.Name }; }; return(entity); }
public void ValidateParameters(UserStatusParam param) { throw new NotImplementedException(); }
public void Update(long id, UserStatusParam param) { Data.Entity.UserStatus oldEntity = Dao.Find(id); Data.Entity.UserStatus newEntity = ParamConverter.Convert(param, oldEntity); Dao.Update(newEntity); }