public ActionResult Create(Product product) { if (ModelState.IsValid) { _context.Products.Add(product); _context.SaveChanges(); return(RedirectToAction("Index")); } var groupList = _context.Categories.Select(c => new SelectListItem { Text = c.Name, Value = c.Id.ToString() }).ToList(); groupList.Insert(0, new SelectListItem { Value = "0", Text = "Seçin", Selected = true, Disabled = true }); ViewBag.Categories = groupList; return(View(product)); }
public ActionResult Edit(Homework homeworkInput, string deleteHomeWorks, List <int> deleteIdsList) { if (!string.IsNullOrEmpty(deleteHomeWorks)) { Delete(deleteIdsList); return(RedirectToAction("Edit")); } //add the homework u get _homeworkDb.DbSet.Add(homeworkInput); _homeworkDb.SaveChanges(); return(RedirectToAction("Edit")); }
public static AccountBook Update(AccountBook account) { var data = (AccountBook)_HomeworkDbContext.AccountBook.Find(account.Id); data.Amounttt = account.Amounttt; data.Categoryyy = account.Categoryyy; data.Dateee = account.Dateee; data.Remarkkk = account.Remarkkk; var result = _HomeworkDbContext.SaveChanges(); return(data); }
public static string Execute(string[] command) { var id = int.Parse(command[1]); var address = string.Join(" ", command.Skip(2)); using (var db = new HomeworkDbContext()) { var employee = db.Employees.Find(id); employee.Address = address; db.SaveChanges(); } return("Address is set"); }
public static string Execute(string[] command) { var id = int.Parse(command[1]); var date = DateTime.ParseExact(command[3], "dd-MM-yyyy", CultureInfo.InvariantCulture); using (var db = new HomeworkDbContext()) { var employee = db.Employees.Find(id); employee.BirthDay = date; db.SaveChanges(); } return($"Birthday is set"); }
public static string Execute(string[] command) { var empId = int.Parse(command[1]); var manId = int.Parse(command[2]); using (var db = new HomeworkDbContext()) { var employee = db.Employees.Find(empId); var manager = db.Employees.Find(manId); manager.Employees.Add(employee); db.SaveChanges(); } return($"Manager with Id {manId} is now a Manager to Employee with Id {empId}"); }
public static string Execute(string[] command) { var firstName = command[1]; var lastName = command[2]; var salary = decimal.Parse(command[3]); using (var db = new HomeworkDbContext()) { var employee = new EmployeeDto() { FirstName = firstName, LastName = lastName, Salary = salary }; db.Employees.Add(Mapper.Map <Employee>(employee)); db.SaveChanges(); } return($"Employee {firstName} {lastName} with Salary {salary} was added"); }
public void SaveChanges() { _context.SaveChanges(); }