Ejemplo n.º 1
0
        public IActionResult Edit(FixedExpanse data)
        {
            try
            {
                var context = new RRRoadwaysDBContext();

                var dbEntry = context.Entry(data);
                dbEntry.Property("StaffSalary").IsModified         = true;
                dbEntry.Property("StaffBhatta").IsModified         = true;
                dbEntry.Property("BhattaDetails").IsModified       = true;
                dbEntry.Property("Donation").IsModified            = true;
                dbEntry.Property("DriverRoomRent").IsModified      = true;
                dbEntry.Property("FormanSalary").IsModified        = true;
                dbEntry.Property("ExtraDriversSalary").IsModified  = true;
                dbEntry.Property("ExtraExpense").IsModified        = true;
                dbEntry.Property("ExtraExpenseDetails").IsModified = true;

                context.SaveChanges();
                ViewBag.vehicleId = new SelectList(context.Vehicle.Where(x => x.IsDeleted == false).ToList(), "Id", "VehicleNumber");
                ViewBag.result    = "Record Updated Successfully!";
            }
            catch (Exception e)
            {
                var error = e;
                ViewBag.error = e.Message;
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public IActionResult Add(FixedExpanse data)
        {
            try
            {
                var context = new RRRoadwaysDBContext();
                context.Add(data);
                context.SaveChanges();

                ViewBag.vehicleId = new SelectList(context.Vehicle.Where(x => x.IsDeleted == false).ToList(), "Id", "VehicleNumber");
                ViewBag.result    = "Record Saved Successfully!";
            }
            catch (Exception e)
            {
                var error = e;
                ViewBag.error = e.Message;
            }
            ModelState.Clear();
            return(RedirectToAction("Index"));
        }