Esempio n. 1
0
        public IActionResult AddBilling(ServiceReport model)
        {
            if (HttpContext.Session.GetString("LoginID") == null)
            {
                return(RedirectToAction("Login", "Users"));
            }
            if (ModelState.IsValid)
            {
                if (model.Labour < 0 || model.Others < 0 || model.Parts < 0 || model.Transport < 0)
                {
                    ModelState.AddModelError("", "Costs cannot be negative");
                    return(View(model));
                }
                if (model.InvoiceNo < 0)
                {
                    ModelState.AddModelError("", "Invoice number cannot be negative");
                    return(View(model));
                }


                CentricsContext context = HttpContext.RequestServices.GetService(typeof(Centrics.Models.CentricsContext)) as CentricsContext;
                context.AddBilling(model);

                return(RedirectToAction("Report", model.SerialNumber));
            }
            ModelState.AddModelError("", "Error have occured");
            return(View(model));
        }