public void SaveOverhead(Overhead overhead) { using (var dbContext = new ProjectDbContext()) { var budgets = dbContext.Budgets.ToList(); if (overhead.ID > 0) { if (overhead.OverheadTotal > 0) { foreach (var budget in budgets) { if (budget.ProjectID == overhead.ProjectID) { budget.OverheadID = overhead.ID; dbContext.Update <BudgetInfo>(budget); } } } dbContext.Update <Overhead>(overhead); } else { dbContext.Insert <Overhead>(overhead); } } }
public void SaveMachineryCost(MachineryCost machinerycost) { using (var dbContext = new ProjectDbContext()) { if (machinerycost.ID > 0) { var budgets = dbContext.Budgets.ToList(); if (machinerycost.MachineryTotal > 0) { foreach (var budget in budgets) { if (budget.ProjectID == machinerycost.ProjectID) { budget.MachineryCostID = machinerycost.ID; dbContext.Update <BudgetInfo>(budget); } } } dbContext.Update <MachineryCost>(machinerycost); } else { dbContext.Insert <MachineryCost>(machinerycost); } } }
public void SaveMeasure(Measure measure) { using (var dbContext = new ProjectDbContext()) { if (measure.ID > 0) { var budgets = dbContext.Budgets.ToList(); if (measure.MeasureTotal > 0) { foreach (var budget in budgets) { if (budget.ProjectID == measure.ProjectID) { budget.MeasureID = measure.ID; dbContext.Update <BudgetInfo>(budget); } } } dbContext.Update <Measure>(measure); } else { dbContext.Insert <Measure>(measure); } } }
public void SaveLaborCost(LaborCost laborcost) { using (var dbContext = new ProjectDbContext()) { if (laborcost.ID > 0) { var budgets = dbContext.Budgets.ToList(); if (laborcost.LaborTotal > 0) { foreach (var budget in budgets) { if (budget.ProjectID == laborcost.ProjectID) { budget.LaborCostID = laborcost.ID; dbContext.Update <BudgetInfo>(budget); } } } dbContext.Update <LaborCost>(laborcost); } else { dbContext.Insert <LaborCost>(laborcost); } } }
public void Update(TEntity entity) { TEntity databaseEntity = (from e in _dbSet where e.Id.Equals(entity.Id) select e).FirstOrDefault(); TId originalId = databaseEntity.Id; EntityHelper.CopyProperties(entity, databaseEntity); databaseEntity.Id = originalId; _dbContext.Update(databaseEntity); _dbContext.SaveChanges(); _dbContext.DetachAll(); }
public void SaveInsMachineryCost(InsMachineryCost insmachinerycost) { using (var dbContext = new ProjectDbContext()) { if (insmachinerycost.ID > 0) { //var budgets = dbContext.Budgets.ToList(); //if (machinerycost.MachineryTotal > 0) //{ // foreach (var budget in budgets) // { // if (budget.ProjectID == machinerycost.ProjectID) // { // budget.MachineryCostID = machinerycost.ID; // dbContext.Update<BudgetInfo>(budget); // } // } //} dbContext.Update <InsMachineryCost>(insmachinerycost); } else { dbContext.Insert <InsMachineryCost>(insmachinerycost); } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,MainPhoto,Price,SalePercent,GuaranteeDate,GuaranteePrice,Condition,ShipDate,ShipPrice,TestDate,Specification,SubCategoryItemsId,IsInBasket")] Product product) { if (id != product.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SubCategoryItemsId"] = new SelectList(_context.SubCategoryItems, "Id", "Name", product.SubCategoryItemsId); return(View(product)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,EmpKey,ProjKey,authorized_assignment")] ProjectAssignment projectAssignment) { if (id != projectAssignment.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(projectAssignment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectAssignmentExists(projectAssignment.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(projectAssignment)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Specification specification) { if (id != specification.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(specification); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpecificationExists(specification.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(specification)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,Building_type,Constructed_date,Stories,OwnerId")] Building building) { if (id != building.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(building); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BuildingExists(building.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["OwnerId"] = new SelectList(_context.Owners, "Id", "Email", building.OwnerId); return(View(building)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,SubCategoryItemsId")] Marka marka) { if (id != marka.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(marka); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MarkaExists(marka.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SubCategoryItemsId"] = new SelectList(_context.SubCategoryItems, "Id", "Name", marka.SubCategoryItemsId); return(View(marka)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,CUSTOMER_NAME,CUSTOMER_ACCOUNT")] CustomerModel customerModel) { if (id != customerModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customerModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerModelExists(customerModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customerModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Date,Discount,ExpiryDate")] OfferHeader offerHeader) { if (id != offerHeader.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(offerHeader); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OfferHeaderExists(offerHeader.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(offerHeader)); }
public ActionResult EditConfirm(int id, Project projectModel) { db.Update(projectModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public void SaveInsMeasure(InsMeasure insmeasure) { using (var dbContext = new ProjectDbContext()) { if (insmeasure.ID > 0) { //var budgets = dbContext.Budgets.ToList(); //if (measure.MeasureTotal > 0) //{ // foreach (var budget in budgets) // { // if (budget.ProjectID == measure.ProjectID) // { // budget.MeasureID = measure.ID; // dbContext.Update<BudgetInfo>(budget); // } // } //} dbContext.Update <InsMeasure>(insmeasure); } else { dbContext.Insert <InsMeasure>(insmeasure); } } }
public async Task <IActionResult> Edit(int id, [Bind("Value,ProductId,SpecificationId")] ProductSpec productSpec) { if (id != productSpec.SpecificationId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(productSpec); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductSpecExists(productSpec.SpecificationId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Name", productSpec.ProductId); ViewData["SpecificationId"] = new SelectList(_context.Specification, "Id", "Name", productSpec.SpecificationId); return(View(productSpec)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Path,ProductId")] Photo photo) { if (id != photo.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(photo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhotoExists(photo.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Products, "Id", "MainPhoto", photo.ProductId); return(View(photo)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,First_name,Last_name,Age,Email,Ssn")] Owner owner) { if (id != owner.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(owner); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OwnerExists(owner.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(owner)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ProductName,Price")] Product product) { if (id != product.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Edit(int id, [Bind("DailyTaskId,Description")] DailyTask dailyTask) { if (id != dailyTask.DailyTaskId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dailyTask); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DailyTaskExists(dailyTask.DailyTaskId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(dailyTask)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,ProjectId,AssignedBy,WBSSummary,WBSHours,StartDate,EndDate,WBSCost")] WBSModel wBSModel) { if (id != wBSModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(wBSModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WBSModelExists(wBSModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(wBSModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,PublishedDate,Image")] News news) { if (id != news.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(news); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NewsExists(news.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(news)); }
public bool Update(Post model) { try { var originalModel = _projectDbContext.Post.Single(x => x.Id == model.Id); originalModel.Id = model.Id; originalModel.Logo = model.Logo; originalModel.NombreCalle = model.NombreCalle; originalModel.NombreCategoria = model.NombreCategoria; originalModel.NombreCiudad = model.NombreCiudad; originalModel.NombrePais = model.NombrePais; originalModel.NombrePosicion = model.NombrePosicion; originalModel.NombreTipoTrabajo = model.NombreTipoTrabajo; originalModel.Poster = model.Poster; originalModel.Descripcion = model.Descripcion; originalModel.DireccionUrl = model.DireccionUrl; _projectDbContext.Update(originalModel); _projectDbContext.SaveChanges(); } catch (Exception e) { return(false); } return(true); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Abrv")] VehicleMake vehicle) { if (id != vehicle.Id) { return(NotFound()); } if (ModelState.IsValid) { try { DbContext.Update(vehicle); await DbContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VehicleMakeExists(vehicle.Id)) { return(NotFound()); } } return(RedirectToAction(nameof(Index))); } return(View(vehicle)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Estado")] Category category) { if (id != category.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CategoryId")] SubCategory subCategory) { if (id != subCategory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(subCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubCategoryExists(subCategory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", subCategory.CategoryId); return(View(subCategory)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Email,PhoneNumber")] Contact contact) { if (id != contact.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(contact); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ContactExists(contact.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(contact)); }
public void SaveInsOverhead(InsOverhead insoverhead) { using (var dbContext = new ProjectDbContext()) { //var budgets = dbContext.Budgets.ToList(); if (insoverhead.ID > 0) { // if (overhead.OverheadTotal > 0) // { // foreach (var budget in budgets) // { // if (budget.ProjectID == overhead.ProjectID) // { // budget.OverheadID = overhead.ID; // dbContext.Update<BudgetInfo>(budget); // } // } // } dbContext.Update <InsOverhead>(insoverhead); } else { dbContext.Insert <InsOverhead>(insoverhead); } } }
public IActionResult Edit(Department department) { if (ModelState.IsValid) { _context.Update(department); _context.SaveChanges(); } return(RedirectToAction("Index")); }
public void SaveBudget(BudgetInfo budget) { using (var dbContext = new ProjectDbContext()) { if (budget.ID > 0) { dbContext.Update <BudgetInfo>(budget); } else { dbContext.Insert <BudgetInfo>(budget); } } }