Example #1
0
 public async Task <IActionResult> CreateRabbit(MRabbitsFemaleDoeBreadersRecords rabbit)
 {
     ViewBag.title = "Create Rabbit";
     try
     {
         rabbit.NameIdBuck = rabbit.NameIdBuck.ToUpper();
         rabbit.NameIdDoe  = rabbit.NameIdDoe.ToUpper();
         db.MRabbitsFemaleDoeBreadersRecords.Add(rabbit);
         TempData["type"] = "success";
         TempData["msg"]  = "Saved";
         await db.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         TempData["type"] = "error";
         TempData["msg"]  = "Error: " + ex.Message;
     }
     return(RedirectToAction("AllRabbits"));
 }
Example #2
0
        public async Task <IActionResult> EditRabbit(MRabbitsFemaleDoeBreadersRecords rabbit)
        {
            ViewBag.title = "Edit Rabbit";
            try
            {
                rabbit.NameIdBuck      = rabbit.NameIdBuck.ToUpper();
                rabbit.NameIdDoe       = rabbit.NameIdDoe.ToUpper();
                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", "RabbitsFemaleDoeBreadersRecords", new { id = rabbit.Id }));
        }