public ActionResult Edit(TechnicalServiceReceipt item)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_Edit", item));
            }

            var entity = TechnicalServiceReceipt.Find(item.Id);

            entity.Brand        = item.Brand;
            entity.Equipment    = item.Equipment;
            entity.Model        = item.Model;
            entity.SerialNumber = item.SerialNumber;
            entity.Date         = item.Date;
            entity.Status       = item.Status;
            entity.Location     = item.Location;
            entity.Checker      = item.Checker;
            entity.Comment      = item.Comment;

            using (var scope = new TransactionScope()) {
                entity.UpdateAndFlush();
            }

            return(PartialView("_Refresh"));
        }
        public ActionResult Create(TechnicalServiceReceipt item)
        {
            if (!ModelState.IsValid) {
                return PartialView ("_Create", item);
            }

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            return PartialView ("_CreateSuccesful", item);
        }
        public ActionResult Create(TechnicalServiceReceipt item)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_Create", item));
            }

            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            return(PartialView("_CreateSuccesful", item));
        }
        public ActionResult CreateComponent(TechnicalServiceReceiptComponent item)
        {
            ViewBag.ReceiptId = item.ReceiptId;

            if (!ModelState.IsValid)
            {
                return(PartialView("_CreateComponent", item));
            }

            item.Receipt = TechnicalServiceReceipt.TryFind(item.ReceiptId);

            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            return(PartialView("_CreateComponentSuccesful", item));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            var item = TechnicalServiceReceipt.Find(id);

            try {
                using (var scope = new TransactionScope()) {
                    foreach (var x in item.Components)
                    {
                        x.DeleteAndFlush();
                    }

                    item.DeleteAndFlush();
                }
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(ex);
                return(PartialView("DeleteUnsuccessful"));
            }

            return(PartialView("_DeleteSuccesful", item));
        }
        public ActionResult Print(int id)
        {
            var item = TechnicalServiceReceipt.Find(id);

            return(View(item));
        }
        public ActionResult Delete(int id)
        {
            var item = TechnicalServiceReceipt.Find(id);

            return(PartialView("_Delete", item));
        }
        public ActionResult Details(int id)
        {
            var item = TechnicalServiceReceipt.Find(id);

            return(View("Details", item));
        }
        public ActionResult Edit(TechnicalServiceReceipt item)
        {
            if (!ModelState.IsValid) {
                return PartialView ("_Edit", item);
            }

            var entity = TechnicalServiceReceipt.Find (item.Id);

            entity.Brand = item.Brand;
            entity.Equipment = item.Equipment;
            entity.Model = item.Model;
            entity.SerialNumber = item.SerialNumber;
            entity.Date = item.Date;
            entity.Status = item.Status;
            entity.Location = item.Location;
            entity.Checker = item.Checker;
            entity.Comment = item.Comment;

            using (var scope = new TransactionScope ()) {
                entity.UpdateAndFlush ();
            }

            return PartialView ("_Refresh");
        }