Exemplo n.º 1
0
        public async Task <IActionResult> EditRabbit(MRabbitsSalesRecords rabbit)
        {
            ViewBag.title = "Edit Rabbit";
            try
            {
                db.Entry(rabbit).State = EntityState.Modified;
                await db.SaveChangesAsync();

                TempData["msg"]  = "Saved";
                TempData["type"] = "success";
            }
            catch (Exception ex)
            {
                TempData["msg"]  = ex.Message;
                TempData["type"] = "error";
            }
            return(RedirectToAction("EditRabbit", "RabbitsSales", new { id = rabbit.Id }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreateRabbitSaleRecord(MRabbitsSalesRecords rabbit)
        {
            ViewBag.title = "Create Rabbit";
            try
            {
                rabbit.NameId = rabbit.NameId.ToUpper();
                db.MRabbitsSalesRecords.Add(rabbit);
                TempData["type"] = "success";
                TempData["msg"]  = "Saved";
                await db.SaveChangesAsync();

                return(RedirectToAction("AllRabbits"));
            }
            catch (Exception ex)
            {
                TempData["type"] = "error";
                TempData["msg"]  = "Error: " + ex.Message;
                return(RedirectToAction($"CreateRabbit", "Rabbits"));
            }
        }