public Alertas_detalle Edit(Alertas_detalle model)
 {
     entities.Alertas_detalle.Attach(model);
       entities.ObjectStateManager.ChangeObjectState(model, EntityState.Modified);
       this.Commit();
       return model;
 }
        public void CreateAlertsDetail(int idAlerta, int idEmpresa, string userName)
        {
            List<Centros> listCentros = new CentrosRepository().GetListCentrosByEmpresa(idEmpresa).ToList();

              foreach (var item in listCentros)
              {
            Alertas_detalle _Alertas_detalle = new Alertas_detalle();
            _Alertas_detalle.Id_alerta = idAlerta;
            _Alertas_detalle.Id_centro = item.Id_centro;
            new Alertas_detalleRepository().Create(_Alertas_detalle);
              }
        }
        public ActionResult Edit_detalle(Alertas_detalle model, FormCollection formCollection)
        {
            try
              {
            if (formCollection["item.unidades.Value"] != null)
            {
              string[] EanIds = formCollection["item.Id_ean"].Split(new Char[] { ',' });
              string[] CantidadEan = formCollection["item.unidades.Value"].Split(new Char[] { ',' });

              decimal totalUnidades = 0;
              for (int i = 0; i < EanIds.Length; i++)
              {
            Alertas_detalle_EAN _Alertas_detalle_EAN = new Alertas_detalle_EANRepository().GetAlertas_detalle_EANByEan(Convert.ToInt32(EanIds[i]));
            Alertas_detalle_EAN _Alertas_detalle_EANEditado = new Alertas_detalle_EAN();
            if (_Alertas_detalle_EAN != null)
            {
              _Alertas_detalle_EANEditado.unidades = Convert.ToDecimal(CantidadEan[i]);
              _Alertas_detalle_EANEditado.Id_alerta_detalle = _Alertas_detalle_EAN.Id_alerta_detalle;
              _Alertas_detalle_EANEditado.Id_ean = _Alertas_detalle_EAN.Id_ean;
              _Alertas_detalle_EANEditado.Id_alerta_detalle_ean = _Alertas_detalle_EAN.Id_alerta_detalle_ean;
              _Alertas_detalle_EANEditado.EntityKey = _Alertas_detalle_EAN.EntityKey;

              totalUnidades += _Alertas_detalle_EANEditado.unidades.Value;
              new Alertas_detalle_EANRepository().Edit(_Alertas_detalle_EANEditado);

            }
              }
              model.Total_cantidad_retirada = totalUnidades;
              new Alertas_detalleRepository().Edit(model);

              return Json(JsonResponseFactory.SuccessResponse(), JsonRequestBehavior.AllowGet);
            }
            else
            {
              new Alertas_detalleRepository().Edit(model);

              return Json(JsonResponseFactory.SuccessResponse(), JsonRequestBehavior.AllowGet);
            }
              }
              catch (Exception ex)
              {
            TempData["ErrorMessage"] = ex.Message;
            return Json(JsonResponseFactory.ErrorResponse(ex.Message), JsonRequestBehavior.AllowGet);

            //return View(model);
              }
        }
 public Alertas_detalle Create(Alertas_detalle model)
 {
     entities.Alertas_detalle.AddObject(model);
       this.Commit();
       return model;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Alertas_detalle EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAlertas_detalle(Alertas_detalle alertas_detalle)
 {
     base.AddObject("Alertas_detalle", alertas_detalle);
 }
 /// <summary>
 /// Create a new Alertas_detalle object.
 /// </summary>
 /// <param name="id_alerta_detalle">Initial value of the Id_alerta_detalle property.</param>
 public static Alertas_detalle CreateAlertas_detalle(global::System.Int32 id_alerta_detalle)
 {
     Alertas_detalle alertas_detalle = new Alertas_detalle();
     alertas_detalle.Id_alerta_detalle = id_alerta_detalle;
     return alertas_detalle;
 }