public ActionResult Create([Bind(Include = "RecognitionID,value,recognitionDescription,recognitionDate,profileID")] Recognition recognition) { Guid memberId; Guid.TryParse(User.Identity.GetUserId(), out memberId); if (memberId == recognition.profileID) { return(View("selfRecognition")); } else { { if (ModelState.IsValid) { db.recognition.Add(recognition); recognition.userName = HttpContext.User.Identity.GetUserId(); db.SaveChanges(); return(RedirectToAction("Index")); } } } ViewBag.CoreValueTypeID = new SelectList(db.recognition, "Value", "CoreValue", recognition.value); ViewBag.profileID = new SelectList(db.profile, "profileID", "employeeFullName", recognition.profileID); return(View(recognition)); }
public ActionResult Create([Bind(Include = "RecognitionID,CoreValueTypeID,recognitionDescription,recognitionDate,profileID")] Recognition recognition) { if (ModelState.IsValid) { db.recognition.Add(recognition); db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.CoreValueTypeID = new SelectList(db.CoreValueType, "CoreValueTypeID", "CoreValueName", recognition.value); ViewBag.profileID = new SelectList(db.profile, "profileID", "employeeFirstName", recognition.profileID); return(View(recognition)); }
public void updateCategory(Category category) { using (var context = new CContext()) { context.Entry(category).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void SaveCategory(Category category) { using (var context = new CContext()) { context.Categories.Add(category); context.SaveChanges(); } }
public void UpdateProducts(Product product) { using (var context = new CContext()) { context.Entry(product).State = EntityState.Modified; context.SaveChanges(); } }
public void InsertPerson() { using (CContext c_ocContext = new CContext()) { CPerson c_peSomeone = new CPerson("Иванов", "Петр", "Сергеевич", new CDateTime(2010, 1, 2)); c_ocContext.Persons.Add(c_peSomeone); Assert.IsTrue(c_ocContext.SaveChanges() > 0); } }
public int SaveOrders(Order order) { using (var _context = new CContext()) { _context.Orders.Add(order); return(_context.SaveChanges()); } }
public void Delete(int id) { using (var context = new CContext()) { var catId = context.Categories.Single(x => x.ID == id); context.Categories.Remove(catId); context.SaveChanges(); } }
public void DeleteProducts(int ID) { using (var context = new CContext()) { var product = context.Products.Where(p => p.ID.Equals(ID)).SingleOrDefault(); context.Products.Remove(product); context.SaveChanges(); } }
public void SaveProducts(Product product) { using (var context = new CContext()) { context.Entry(product).State = EntityState.Unchanged; context.Products.Add(product); context.SaveChanges(); } }
public void DeletePerson() { using (CContext c_ocContext = new CContext()) { CPerson c_peSomeone = c_ocContext.Persons.FirstOrDefault(); Assert.IsNotNull(c_peSomeone); c_ocContext.Persons.Remove(c_peSomeone); Assert.IsTrue(c_ocContext.SaveChanges() > 0); } }
public bool UpdateOrderStatus(int id, string status) { using (var context = new CContext()) { var order = context.Orders.Find(id); order.Status = status; context.Entry(order).State = EntityState.Modified; return(context.SaveChanges() > 0); } }
public static void ConfigureUser(IEnumerable <CUser> users, string connectionString) { using (var db = new CContext(connectionString)) { if (!db.Users.Any()) { foreach (var u in users) { u.Claims.Add(new CUserClaim { ClaimValue = "UserManagementAdmin", ClaimType = Constants.ClaimTypes.Role }); u.Claims.Add(new CUserClaim { ClaimValue = "ClientScopeManagementAdmin", ClaimType = Constants.ClaimTypes.Role }); db.Users.Add(u); } db.SaveChanges(); } } }