示例#1
0
        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 }));
        }
示例#2
0
        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 }));
        }