public ActionResult Create([Bind(Include = "SectionId,Name,StudentId")] Section section) { if (ModelState.IsValid) { db.Sections.Add(section); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StudentId = new SelectList(db.Students, "StudentId", "Name", section.StudentId); return(View(section)); }
public ActionResult Create([Bind(Include = "DepartmentId,Name")] Department department) { if (ModelState.IsValid) { db.Departments.Add(department); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(department)); }
public ActionResult Create([Bind(Include = "Id,Name,Gender,Contact,City,Experience,DepartmentId")] Worker worker) { if (ModelState.IsValid) { db.Workers.Add(worker); db.SaveChanges(); return(PartialView("_Success")); } return(PartialView("Failed")); }
public ActionResult Create([Bind(Include = "StudentId,Name,RegNo,Address,HallName")] Student student) { if (ModelState.IsValid) { db.Students.Add(student); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Create([Bind(Include = "SectionId,DepartmentId,Code,Description")] Section section) { if (ModelState.IsValid) { db.Sections.Add(section); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentId", "Code", section.DepartmentId); return(View(section)); }
public ActionResult Create([Bind(Include = "DepartmentId,Name,Location,StudentId,SectionId")] Department department) { if (ModelState.IsValid) { db.Departments.Add(department); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.StudentId = new SelectList(db.Students, "StudentId", "Name", department.StudentId); ViewBag.SectionId = new SelectList(db.Sections, "SectionId", "Name", department.SectionId); return(View(department)); }
public IActionResult CreateBarrio(Barrio barrio) { _departmentDbContext.Barrio.Add(barrio); _departmentDbContext.SaveChanges(); return(View(barrio)); }
public IActionResult CreateDepartamento(Departamento departamento) { _departmentDbContext.Departamento.Add(departamento); _departmentDbContext.SaveChanges(); return(View(departamento)); }
public IActionResult CreateMunicipio(Municipio municipio) { _departmentDbContext.Municipio.Add(municipio); _departmentDbContext.SaveChanges(); return(View(municipio)); }
public ActionResult Edit(Department department) { if (!ModelState.IsValid) { return(View(department)); } //Currently saved record in the DB Department departmentInDb = _dbContext.Departments .Include("Employees") .FirstOrDefault(d => d.ID == department.ID); departmentInDb.DepartmentName = department.DepartmentName; departmentInDb.Location = department.Location; departmentInDb.DepartmentHead = department.DepartmentHead; _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public Department InsertDepartment(Department department) { dbContext.departments.Add(department); dbContext.SaveChanges(); return(department); }
public async Task <IHttpActionResult> UpdateInvoice(int invoiceId, [FromBody] Invoice model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (invoiceId != model.InvoiceId) { return(BadRequest()); } var existinginvoice = db.Invoices .Where(p => p.InvoiceId == model.InvoiceId) .Include(p => p.InvoiceDetails) .SingleOrDefault(); if (existinginvoice != null) { // Update Invoice db.Entry(existinginvoice).CurrentValues.SetValues(model); foreach (var InvoiceDetail in existinginvoice.InvoiceDetails.ToList()) { if (!model.InvoiceDetails.Any(x => x.InvoiceDetailsId == InvoiceDetail.InvoiceDetailsId)) { db.InvoiceDetails.Remove(InvoiceDetail); db.SaveChanges(); } } foreach (var invoicedetail in model.InvoiceDetails) { var existingInvoiceDetail = existinginvoice.InvoiceDetails .Where(c => c.InvoiceDetailsId == invoicedetail.InvoiceDetailsId) .SingleOrDefault(); if (existingInvoiceDetail != null) { // Update InvoiceDetails db.Entry(existingInvoiceDetail).CurrentValues.SetValues(invoicedetail); } else { existinginvoice.InvoiceDetails.Add(invoicedetail); } db.SaveChanges(); } } try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvoiceExits(invoiceId)) { return(NotFound()); } else { throw; } } return(Ok(new ResponseMessage <Invoice> { Result = model })); }