public JsonResult EditRepair(WatchRepair model)
        {
            var succ = false;

            try
            {
                var repair = _context.WatchRepairs.First(x => x.ID == model.ID);
                repair.Number       = model.Number;
                repair.WatchBrandId = model.WatchBrandId;
                repair.WatchBarcode = model.WatchBarcode;
                repair.Description  = model.Description;
                if (model.StatusId != repair.StatusId)
                {
                    if (model.StatusId == 3 && repair.EndDate == null)
                    {
                        repair.EndDate = DateTime.Now;
                    }
                    else if (model.StatusId == 4 && repair.ReceiptDate == null)
                    {
                        repair.ReceiptDate = DateTime.Now;
                    }
                }
                repair.StatusId = model.StatusId;
                _context.SaveChanges();
                succ = true;
            }
            catch (Exception ex)
            {
            }
            return(new JsonResult {
                Data = new { succ = succ }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public JsonResult AddRepair(WatchRepair model)
        {
            var succ = false;

            try
            {
                if (model.Client.ID != 0)
                {
                    model.ClientId = model.Client.ID;
                    model.Client   = null;
                }
                else
                {
                    model.Client.CreationDate = DateTime.Now;
                }

                model.CreationDate = DateTime.Now;
                model.StatusId     = 1;

                _context.WatchRepairs.Add(model);
                _context.SaveChanges();
                succ = true;
            }
            catch (Exception)
            {
            }

            return(new JsonResult {
                Data = new { succ = succ }, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }