public async Task <IActionResult> Create([Bind("Id,CowNationId,GenderId,CowName,PreCodeNo,OurCodeNo,CowGroupId,CowCollectionId,CowPurposeId,InitialPrice,Description,ManagerSignature,EntryDate")] CowManagement cowManagement)
        {
            if (ModelState.IsValid)
            {
                cowManagement.ManagerSignature = HttpContext.Session.GetString("username");

                _context.Add(cowManagement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CowCollectionId"] = new SelectList(_context.CowCollection, "CowCollectionId", "CowCollectionName", cowManagement.CowCollectionId);
            ViewData["CowGroupId"]      = new SelectList(_context.CowGroup, "CowGroupId", "CowGroupName", cowManagement.CowGroupId);
            ViewData["CowPurposeId"]    = new SelectList(_context.Set <CowPurpose>(), "CowPurposeId", "CowPurposeName", cowManagement.CowPurposeId);
            ViewData["GenderId"]        = new SelectList(_context.Set <Gender>(), "GenderId", "GenderName", cowManagement.GenderId);
            ViewData["CowNationId"]     = new SelectList(_context.Set <NationOfCow>(), "CowNationId", "CowNationName", cowManagement.CowNationId);
            return(View(cowManagement));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,CowNationId,GenderId,CowName,PreCodeNo,OurCodeNo,CowGroupId,CowCollectionId,CowPurposeId,InitialPrice,Description,ManagerSignature,EntryDate")] CowManagement cowManagement)
        {
            if (id != cowManagement.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    cowManagement.ManagerSignature = HttpContext.Session.GetString("username");

                    _context.Update(cowManagement);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CowManagementExists(cowManagement.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CowCollectionId"] = new SelectList(_context.CowCollection, "CowCollectionId", "CowCollectionName", cowManagement.CowCollectionId);
            ViewData["CowGroupId"]      = new SelectList(_context.CowGroup, "CowGroupId", "CowGroupName", cowManagement.CowGroupId);
            ViewData["CowPurposeId"]    = new SelectList(_context.Set <CowPurpose>(), "CowPurposeId", "CowPurposeName", cowManagement.CowPurposeId);
            ViewData["GenderId"]        = new SelectList(_context.Set <Gender>(), "GenderId", "GenderName", cowManagement.GenderId);
            ViewData["CowNationId"]     = new SelectList(_context.Set <NationOfCow>(), "CowNationId", "CowNationName", cowManagement.CowNationId);
            return(View(cowManagement));
        }