public async Task <IActionResult> Add(EquipmentIndexViewModel equipmentIndex)
        {
            if (ModelState.IsValid)
            {
                var equipment = equipmentIndex.EquipmentAdd;
                try
                {
                    var existEqp = await _context.Equipments.SingleOrDefaultAsync(e => e.Category == equipment.Category& e.Type == equipment.Type
                                                                                  & e.Name == equipment.Name& e.Detail == equipment.Detail);

                    if (existEqp == null)
                    {
                        _context.Add(equipment);
                    }
                    else
                    {
                        existEqp.Number += equipment.Number;
                        _context.Update(existEqp);
                    }
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
            }
            return(RedirectToAction("Store"));
        }
        public async Task <IActionResult> Add([Bind("EquipmentId", "Number", "Reason")] Invoice invoice)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var user = await _userManager.GetUserAsync(HttpContext.User);

                    invoice.WorkerId = user.Id;
                    invoice.Date     = DateTime.Now;

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

                    return(RedirectToAction("Index", "Home"));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error
                ModelState.AddModelError("", "无法保存更改,重试或联系系统管理员.");
            }
            return(View(invoice));
        }