public IHttpActionResult SavePlan(MultiDataModel model)
        {
            PlanBE data   = JsonConvert.DeserializeObject <PlanBE>(model.String1);
            var    result = PlanBL.SavePlan(data);

            return(Ok(result));
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
 public static bool SavePlan(PlanBE entityPlan)
 {
     try
     {
         _ctx.Plan.Add(entityPlan);
         _ctx.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 9
0
 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);
     }
 }
Esempio n. 10
0
 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);
     }
 }
Esempio n. 11
0
        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);
            }
        }