//public DisciplineStatusProcessor(IDisciplineStatusDao dao, IDisciplineStatusParamConverter paramConverter, // IDisciplineStatusResultConverter resultConverter) //{ // this.Dao = dao; // this.ParamConverter = paramConverter; // this.ResultConverter = resultConverter; //} public DisciplineStatusResult Create(DisciplineStatusParam param) { Model.DisciplineStatus entity = ParamConverter.Convert(param, null); entity = Dao.Save(entity); return(ResultConverter.Convert(entity)); }
public void Update(long id, DisciplineStatusParam param) { Model.DisciplineStatus 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 DisciplineStatusService(IDisciplineStatusProcessor 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(DisciplineStatusParam 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, DisciplineStatusParam 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.DisciplineStatus Convert(DisciplineStatusParam param, Model.DisciplineStatus oldEntity) { Model.DisciplineStatus entity = null; if (oldEntity != null) { entity = oldEntity; } else { entity = new Model.DisciplineStatus { Code = param.Code, Id = param.Id, Description = param.Description, Name = param.Name }; } return(entity); }
/// <summary> /// /// </summary> /// <param name="param">a entity</param> public void ValidateParameters(DisciplineStatusParam param) { throw new NotImplementedException(); }