public IHttpActionResult SavePlan(MultiDataModel model) { PlanBE data = JsonConvert.DeserializeObject <PlanBE>(model.String1); var result = PlanBL.SavePlan(data); return(Ok(result)); }
public bool Update(long Id, PlanBE Be) { try { var flag = false; if (Be != null) { var entity = Factory.FactoryPlan.GetInstance().CreateEntity(Be); _puente.Planrepository.Update(entity, new List <string>() { "desc_plan" }); _puente.Commit(); flag = true; return(flag); } else { throw new ApiBusinessException(1012, "No se pudo Modificar el plan", System.Net.HttpStatusCode.NotFound, "Http"); } } catch (Exception ex) { throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex); } }
public static MessageCustom SavePlan(PlanBE entityPlan) { MessageCustom msg = new MessageCustom(); var existPlan = PlanDal.ExistPlan(entityPlan); if (!existPlan) { var result = PlanDal.SavePlan(entityPlan); if (!result) { msg.Error = true; msg.Status = (int)HttpStatusCode.BadRequest; msg.Message = "Sucedió un error al grabar el PLAN por favor vuelva a intentar."; } else { msg.Error = false; msg.Status = (int)HttpStatusCode.Created; msg.Message = "Se creó correctamente."; } } else { msg.Error = false; msg.Status = (int)HttpStatusCode.Conflict; msg.Message = "El PLAN ya existe, por favor elija otra configuración."; } return(msg); }
public DataModel.planes CreateEntity(PlanBE be) { DataModel.planes entity = new DataModel.planes() { id_plan = be.id_plan, id_especialidad = be.id_especialidad, desc_plan = be.desc_plan, estado = be.estado }; return(entity); }
public PlanBE CreateBusiness(DataModel.planes entity) { PlanBE be = new PlanBE() { id_plan = entity.id_plan, id_especialidad = entity.id_especialidad, desc_plan = entity.desc_plan, estado = entity.estado }; return(be); }
public PlanDTO CreateDTO(PlanBE be) { PlanDTO dto = new PlanDTO() { id_plan = be.id_plan, desc_plan = be.desc_plan, id_especialidad = be.id_especialidad, Especialidad = be.especialidades != null?FactoryEspecialidadDTO.GetInstance().CreateDTO(be.especialidades) : null, estado = be.estado }; return(dto); }
public static bool ExistPlan(PlanBE data) { try { var result = _ctx.Plan.Where(x => x.v_OrganizationSeguroId == data.v_OrganizationSeguroId && x.v_ProtocoloId == data.v_ProtocoloId && x.v_IdUnidadProductiva == data.v_IdUnidadProductiva).FirstOrDefault(); return(result != null); } catch (Exception ex) { return(true); } }
public static bool SavePlan(PlanBE entityPlan) { try { _ctx.Plan.Add(entityPlan); _ctx.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public async Task <IHttpActionResult> PostPlan(PlanBE plan) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _services.Create(plan); return(Created(new Uri(Url.Link("DefaultApi", new { Id = plan })), plan)); } catch (Exception ex) { var except = (ApiBusinessException)HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex); var resp = BadRequest(Convert.ToString(except.ErrorDescription)); return(resp); } }
public async Task <IHttpActionResult> PutPlan(Int32 id, PlanBE plan) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } plan.id_plan = id; _services.Update(id, plan); return(Ok()); } catch (Exception ex) { var except = (ApiBusinessException)HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex); var resp = BadRequest(Convert.ToString(except.ErrorDescription)); return(resp); } }
public long Create(PlanBE Be) { try { if (Be != null) { DataModel.planes entity = Factory.FactoryPlan.GetInstance().CreateEntity(Be); _puente.Planrepository.Insert(entity); _puente.Commit(); return(entity.id_plan); } else { throw new ApiBusinessException(1012, "No se pudo crear el plan", System.Net.HttpStatusCode.NotFound, "Http"); } } catch (Exception ex) { throw HandlerErrorExceptions.GetInstance().RunCustomExceptions(ex); } }