示例#1
0
        public async Task <ActionResult> Assign([Bind(Include = "ID,Name,EmployeeID")] AssignViewModel assignedItem)
        {
            try
            {
                if (assignedItem.EmployeeID == null)
                {
                    return(RedirectToAction("Assign", new { ID = assignedItem.ID }));
                }
                if (ModelState.IsValid)
                {
                    Guid itemID     = assignedItem.ID;
                    Guid?employeeID = assignedItem.EmployeeID;
                    await Service.AssignItemAsync(itemID, employeeID);

                    return(RedirectToAction("OnStock"));
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again and if the problem persists see your system administrator.");
            }
            return(RedirectToAction("Assign", new { ID = assignedItem.ID }));
        }