public ActionResult Index(LoteModelBag model) { LoteMessageId message = LoteMessageId.Error; int id = 0; try { if (model != null) { if (model.Lote.Id > 0) { model.Lote.Save(); id = model.Lote.Id; message = LoteMessageId.SaveSucess; } else { model.Lote.Fazenda = SysPec.App.Helpers.Current.FazendaId; model.Lote.Add(); id = model.Lote.Id; addAnimaisToLote(model.Lote, model.Animal, model.QtdDeAnimais); message = LoteMessageId.AddSuccess; } } } catch (Exception) { return(RedirectToAction("Index", new { message = LoteMessageId.Error })); } return(RedirectToAction("Index", new { LoteId = id, message = message })); }
public ActionResult AddAnimaisToLote(LoteModelBag model) { LoteMessageId message = LoteMessageId.Error; int id = 0; try { addAnimaisToLote(model.Lote, model.Animal, model.QtdDeAnimais); message = LoteMessageId.AddAnimaisSucess; } catch (Exception) { return(RedirectToAction("Index", new { message = LoteMessageId.Error })); } return(RedirectToAction("Index", new { LoteId = id, message = message })); }