Exemplo n.º 1
0
 public HttpResponseMessage UpdatePlan(PlanModel Model)
 {
     try
     {
         PlanBl Bl     = new PlanBl();
         int    Status = Bl.UpdatePlan(Model);
         if (Status == 1)
         {
             return(new Response <string>("Added Succesfully", "", HttpStatusCode.Created));
         }
         else if (Status == 2)
         {
             return(new Response <string>("already exist", "", HttpStatusCode.Ambiguous));
         }
         else if (Status == 3)
         {
             return(new Response <string>("updated Successfully", "", HttpStatusCode.Created));
         }
         else if (Status == 4)
         {
             return(new Response <string>("Not found", "", HttpStatusCode.NotFound));
         }
         else
         {
             return(new Response <string>("Failed", "", HttpStatusCode.NotImplemented));
         }
     }
     catch (Exception ex)
     {
         return(new Response <string>("Something went wrong", "", HttpStatusCode.ServiceUnavailable));
     }
 }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                //Obtengo la data antes de que se actualize
                OldListPlan = _objPlanBl.ObtenerPlanesPorProtocolo(ref objOperationResult1, _protocolId);

                objOperationResult1 = new OperationResult();
                var data = grd.Rows.Select(p => (planDto)p.ListObject).ToList();
                foreach (var item in data)
                {
                    if (!item.EsCoaseguro && !item.EsDeducible)
                    {
                        MessageBox.Show("Por favor revise todos los tipos de descuento.!");
                        return;
                    }

                    if ((item.d_Importe ?? 0) < 0)
                    {
                        MessageBox.Show("Por favor revise todos los importes de descuento.!");
                        return;
                    }

                    item.i_EsCoaseguro = item.EsCoaseguro ? 1 : 0;
                    item.i_EsDeducible = item.EsDeducible ? 1 : 0;

                    _aseguradoraId = cboEmpresa.Value.ToString() /*.Split('|')[0]*/;
                    item.v_OrganizationSeguroId = _aseguradoraId.Trim();
                }

                var cambiados = SetChangeProtocolComponent(data);

                foreach (var plan in cambiados)
                {
                    var itemData = data.Find(y => y.i_PlanId == Int32.Parse(plan.NombreCampo));
                    if (itemData != null)
                    {
                        data.Find(y => y.i_PlanId == Int32.Parse(plan.NombreCampo)).v_ComentaryUpdate = plan.ValorCampo;
                    }
                }

                _objPlanBl.UpdatePlan(_aseguradoraId, _protocolId, data, _listToDelete);
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }