public ActionResult ServiceOnTheFly([Bind(Include = "Id,ServiceName,DepartmentId,CashPrice")] CaresoftHMISDataAccess.Service service)
        {
            service.DateAdded = DateTime.Now;
            try
            {
                db.Services.Add(service);
                db.SaveChanges();
                return(Json(new {
                    Message = "<b>" + service.ServiceName + "</b> Added Successfully!",
                    Status = true,
                    ServiceId = service.Id,
                    ServiceName = service.ServiceName,
                    CashPrice = service.CashPrice
                }));
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);


                var fullErrorMessage = string.Join("; ", errorMessages);


                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);


                return(Content(exceptionMessage));
            }
        }
        public ActionResult Service([Bind(Include = "Id,ServiceName,DepartmentId,CashPrice")] CaresoftHMISDataAccess.Service service)
        {
            service.DateAdded = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Services.Add(service);
                db.SaveChanges();
                return(RedirectToAction("Service"));
            }

            ServicesData serviceData = new ServicesData();

            serviceData.Services        = db.Services.ToList();
            serviceData.Service         = service;
            serviceData.DepartmentsList = db.Departments.ToList();
            return(View(serviceData));
        }