public ActionResult Edit(Support support) { fillUserData(); if (ModelState.IsValid) { //New Files for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); FileDetail fileDetail = new FileDetail() { FileName = fileName, Extension = Path.GetExtension(fileName), Id = Guid.NewGuid(), SupportId = support.SupportId }; var path = Path.Combine(Server.MapPath("~/Images/"), fileDetail.Id + fileDetail.Extension); file.SaveAs(path); db.Entry(fileDetail).State = EntityState.Added; } } db.Entry(support).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("EmployeeDocs", new { Employeeid = support.EmpId })); } return(View(support)); }
public async Task <ActionResult> Edit([Bind(Include = "id,CreationDate,LastModificationDate,Name,Address,AddressInArabic,Email,EmployeeImage,Nationality,BirthDate,Sex,BirthPlace")] EmployeeProspect employeeprospect) { fillUserData(); if (ModelState.IsValid) { db.Entry(employeeprospect).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(employeeprospect)); }
public ActionResult Edit(Employees employees, HttpPostedFileBase upload) { fillUserData(); if (ModelState.IsValid) { string oldpath = employees.EmployeeImage; if (upload != null) { System.IO.File.Delete(oldpath); string path = Path.Combine(Server.MapPath("~/Images"), upload.FileName); upload.SaveAs(path); employees.EmployeeImage = upload.FileName; } var depMap = new Dictionary <string, string> { { "Management", "01" }, { "HR", "02" }, { "IT", "03" }, { "Accounting", "04" }, { "Marketing & Selling", "05" }, { "Quality Management", "06" }, { "HSE", "07" }, { "WireLine", "08" }, { "Slickline", "09" }, { "Coiled Tubing", "10" }, { "FRAC Pumping", "11" }, { "Drilling", "12" }, { "Testing", "13" } }; var countryMap = new Dictionary <string, string> { { "Syria", "63" }, { "Lebanon", "61" }, { "Egypt", "20" }, { "Iraq", "64" } }; string month = employees.StartDate.ToString("MM"); string year = employees.StartDate.ToString("yy"); employees.EmployeeCode = depMap[employees.Department] + month + year + countryMap[employees.Country] + employees.EId; employees.lastModificationDate = DateTime.Now; db.Entry(employees).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("PersonalPage", new { Employeeid = employees.Id })); } return(View(employees)); }
public async Task <IActionResult> PutCovidTesting(int id, CovidTesting covidTesting) { if (id != covidTesting.Id) { return(BadRequest()); } _context.Entry(covidTesting).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CovidTestingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static int UpdateProductDetails(string bq, string colName, string value) { int succes = 0; using (var context = new ApplicationDataContext()) { prod = context.products.Where(p => p.bq_number == bq).Single <Products>(); } if (prod != null) { if (colName == "unit_price") { prod.unit_price = Convert.ToDecimal(value); } if (colName == "product_Name") { prod.product_name = value; } if (colName == "bulk_price") { prod.bulk_price = Convert.ToDecimal(value); } if (colName == "tooLowAlertNum") { prod.tooLowAlertNum = Convert.ToInt32(value); } using (var con = new ApplicationDataContext()) { con.Entry(prod).State = EntityState.Modified; succes = con.SaveChanges(); } } return(succes); }
public static int AddProductQuantity(int productId, int qnty) { try { int saves = 0; using (var context = new ApplicationDataContext()) { prod = context.products.Where(s => s.id == productId).FirstOrDefault <Products>(); } if (prod != null) { prod.quantity = prod.quantity + qnty; using (var context = new ApplicationDataContext()) { context.Entry(prod).State = EntityState.Modified; saves = context.SaveChanges(); } } return(saves); } catch (Exception) { throw; } }
/// <summary> /// Updating Products if the products already exist /// </summary> /// <param name="bqnum"></param> /// <param name="lastStockDate"></param> /// <param name="quantity"></param> /// <returns></returns> public static int AddProducts(string bqnum, int quantity, decimal prize) { try { int saves = 0; using (var context = new ApplicationDataContext()) { prod = context.products.Where(s => s.bq_number == bqnum).FirstOrDefault <Products>(); } if (prod != null) { if (prize != Convert.ToDecimal(0)) { prod.unit_price = prize; } prod.quantity = prod.quantity + quantity; prod.last_stock_date = System.DateTime.UtcNow; using (var context = new ApplicationDataContext()) { context.Entry(prod).State = EntityState.Modified; saves = context.SaveChanges(); } } return(saves); } catch (Exception) { throw; } }
public async Task <IActionResult> PutAppUser(int id, AppUser appUser) { if (id != appUser.Id) { return(BadRequest()); } _context.Entry(appUser).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppUserExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutLogisticCompany(int Id, LogisticCompany logisticCompany) { if (Id != logisticCompany.Id) { return(BadRequest()); } _context.Entry(logisticCompany).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LogisticCompanyExists(Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static int UpdateSalesPrice(int id, decimal newSalesPrice) { try { int saves = 0; using (var context = new ApplicationDataContext()) { sales = context.sales.Where(x => x.id == id).FirstOrDefault <Sales>(); } if (sales != null) { sales.sales_amount = newSalesPrice; using (var context = new ApplicationDataContext()) { context.Entry(sales).State = EntityState.Modified; saves = context.SaveChanges(); } } return(saves); } catch (Exception) { throw; } }
public static int UpdateQuantityandNewPrice(int id, int quantity, decimal Newprice) { try { int saves = 0; using (var context = new ApplicationDataContext()) { prodsales = context.products_sales.Where(s => s.id == id).FirstOrDefault <ProductSales>(); } if (prodsales != null) { prodsales.amount_paid = Newprice; prodsales.quantity -= quantity; using (var context = new ApplicationDataContext()) { context.Entry(prodsales).State = EntityState.Modified; saves = context.SaveChanges(); } } return(saves); } catch (Exception) { throw; } }
private async IAsyncEnumerable <Product> GetProductsCore2Async(ProductCategory category) { var products = dataContext.Products .Include(p => p.Category) .Include("Images.Image") .Where(p => p.Category.Id == category.Id).AsQueryable(); foreach (var product in products.AsQueryable()) { yield return(product); } await dataContext .Entry(category) .Collection(c => c.ChildCategories) .LoadAsync(); foreach (var childCategory in category.ChildCategories) { await foreach (var productDto in GetProductsCore2Async(childCategory)) { yield return(productDto); } } }
public ActionResponse Save(UserDto obj) { try { var dao = Mapper.Map <UserDao>(obj); if (obj.Id == default(Guid)) { var response = _userManager.Create(dao); if (!response.Succeeded) { return(ActionResponse.Failure(response.Errors.ToArray())); } var user = _userManager.FindByEmail(obj.Email); if (user == null) { return(ActionResponse.Failure($"User not found for email={obj.Email.ToString()}")); } return(ActionResponse.Succeed()); } else { using (ApplicationDataContext ctx = new ApplicationDataContext()) { ctx.Entry(dao).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } return(ActionResponse.Succeed()); } } catch (Exception exc) { return(ActionResponse.Failure(exc.Message)); } }
public ActionResult Edit([Bind(Include = "id,AnnouncementDate,ClosingDate,Title,Location,MilitaryService,Status,Category,Breifdescreption,Detaileddescreption,jobRequierment,AverageSalary")] Job job) { fillUserData(); if (ModelState.IsValid) { Job oldJob = db.Jobs.Find(job.id); oldJob.AnnouncementDate = job.AnnouncementDate; oldJob.AverageSalary = job.AverageSalary; oldJob.Breifdescreption = job.Breifdescreption; oldJob.Category = job.Category; oldJob.ClosingDate = job.ClosingDate; oldJob.Detaileddescreption = job.Detaileddescreption; oldJob.jobRequierment = job.jobRequierment; oldJob.LastModificationDate = DateTime.Now; oldJob.Location = job.Location; oldJob.MilitaryService = job.MilitaryService; oldJob.Status = job.Status; oldJob.Title = job.Title; db.Entry(oldJob).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(job)); }
public static int AddStock(string bqnum, int quantity, decimal costprice) { try { int saves = 0; using (var context = new ApplicationDataContext()) { stock = context.stocks.Where(s => s.product_BQ == bqnum).FirstOrDefault <Stock>(); } if (stock != null) { stock.bulk_quantity = stock.bulk_quantity + quantity; if (costprice == 0) { stock.cost_price = stock.cost_price; } else { stock.cost_price = costprice; } using (var context = new ApplicationDataContext()) { context.Entry(stock).State = EntityState.Modified; saves = context.SaveChanges(); } } return(saves); } catch (Exception) { throw; } }
public ActionResult Edit(Question question, int TestId) { fillUserData(); if (ModelState.IsValid) { Question questionToUpdate = db .Questions .Where(q => q.Id == question.Id) .FirstOrDefault(); TryUpdateModel(questionToUpdate); questionToUpdate.QuestionType = db .QuestionCategories .Where(cat => cat.Id == question.CategoryId) .Select(cat => cat.Category) .FirstOrDefault(); db.Entry(questionToUpdate).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("QuestionPage", new { TestId })); } else { ViewBag.Test = db .Tests .Where(t => t.Id == TestId) .FirstOrDefault(); return(View(question)); } }
public async Task <IActionResult> UpdateSucursal([FromRoute] int idSucursal, [FromBody] Sucursal sucursal) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _dataContext.Entry(sucursal).State = EntityState.Modified; try { await _dataContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SucursalExists(idSucursal)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ToRespond> MakePlacementEligible(int studentId) { var student = await _dataContext.Students.Where(x => x.StudentId == studentId) .Where(x => x.EligiblityStatus == Helpers.Pending) .Include(x => x.Placement) .FirstOrDefaultAsync(); if (student == null) { return(new ToRespond() { StatusCode = Helpers.NotFound, StatusMessage = Helpers.StatusMessageNotFound }); } student.EligiblityStatus = Helpers.Eligible; _dataContext.Entry(student).State = EntityState.Modified; var result = await _globalRepository.SaveAll(); if (result != null) { if (!result.Value) { return(new ToRespond() { StatusCode = Helpers.SaveError, StatusMessage = Helpers.StatusMessageSaveError }); } // await dbTransaction.CommitAsync(); return(new ToRespond() { StatusCode = Helpers.Success, ObjectValue = _mapper.Map <StudentResponse>(student), }); } return(new ToRespond() { StatusCode = Helpers.SaveError, StatusMessage = Helpers.StatusMessageSaveError }); }
public ActionResult Edit([Bind(Include = "TransId,transDate,OrNo,product,transQtyPurch,cashier")] Sales sales) { if (ModelState.IsValid) { db.Entry(sales).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sales)); }
public ActionResult Edit([Bind(Include = "prodId,prodName,prodStockQty,prodStockReq,prodPrice")] Inventory inventory) { if (ModelState.IsValid) { db.Entry(inventory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(inventory)); }
public ActionResult Edit([Bind(Include = "Id,Data")] ExistingTable existingTable) { if (ModelState.IsValid) { db.Entry(existingTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(existingTable)); }
public ActionResult Edit([Bind(Include = "Id,Title")] Subject subject) { if (ModelState.IsValid) { db.Entry(subject).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(subject)); }
public ActionResult Edit([Bind(Include = "id,PhoneNumber,JobId,EmailAddress,FirstName,LastName,FilePath")] JobRequest jobrequest) { if (ModelState.IsValid) { db.Entry(jobrequest).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(jobrequest)); }
public async Task <WalletGroupModel> GetByIdAsync(string id) { var walletGroup = await applicationDataContext.WalletGroups.FindAsync(id); if (walletGroup != null) { applicationDataContext.Entry(walletGroup).State = EntityState.Detached; } return(walletGroup); }
public async Task <ProcessamentModel> GetByUserCPFAsync(string cpf) { var processament = await applicationDataContext.Processaments.Where(x => x.UserCPF == cpf).FirstOrDefaultAsync(); if (processament != null) { applicationDataContext.Entry(processament).State = EntityState.Detached; } return(processament); }
public ActionResult Edit([Bind(Include = "id,Comment,Date")] ArticleComment articlecomment) { fillUserData(); if (ModelState.IsValid) { db.Entry(articlecomment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(articlecomment)); }
public ActionResult Edit([Bind(Include = "id,Name,Email,Message,Date")] ContactUs contactus) { fillUserData(); if (ModelState.IsValid) { db.Entry(contactus).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(contactus)); }
private async Task MessageDeletedAsync(Cacheable <IMessage, ulong> arg1, ISocketMessageChannel arg2) { using (var db = new ApplicationDataContext()) { var msg = await DiscordMessage.CreateOrGetAsync(await arg1.GetOrDownloadAsync()); db.Entry(msg); msg.IsDeleted = true; await db.SaveChangesAsync(); } }
public ActionResult Edit([Bind(Include = "Id,Album_Id,Quantity,TransactionDate,Price")] Transaction transaction) { if (ModelState.IsValid) { _context.Entry(transaction).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Album_Id = new SelectList(_context.Albums, "Id", "Title", transaction.Album_Id); return(View(transaction)); }
public async Task <UserModel> GetByCPFAsync(string cpf) { var user = await applicationDataContext.Users.FindAsync(cpf); if (user != null) { applicationDataContext.Entry(user).State = EntityState.Detached; } return(user); }