public IActionResult editVendor(int vid) { TblVendor obj = ourdbCntxt.TblVendor.Where(abc => abc.VendorId == vid).FirstOrDefault <TblVendor>(); // return RedirectToAction(nameof(FirstController.editVendor)); return(View(obj)); }
public IActionResult addVendor(TblVendor tv) { //var t = ourdbCntxt.TblVendor.Find(tv.vendorId); ourdbCntxt.TblVendor.Add(tv); ourdbCntxt.SaveChanges(); return(RedirectToAction(nameof(VendorsController.viewAllVendors))); }
public async Task <IActionResult> Edit(string id, [Bind("Id,Name,ContactPerson,ContactNo,PhoneNo,VendorType,Type,Place,Dob,Gstno,Tinno,Panno,Cinno,AdhaarNo,OpeningBalance,OpeningBalanceType,OpeningBalanceDate,CreditLimit,CreditPeriod,CreditInterestRate,DebitInterestRate,CreatedDatetime,Photo,Remark,SuretyPerson,SuretyPersonContactNo,SuretyPersonAddress")] TblVendor tblVendor) { if (id != tblVendor.Id) { return(NotFound()); } if (ModelState.IsValid) { try { //_context.Update(tblVendor).Property(x => x.AutoId).IsModified = false; _context.Update(tblVendor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TblVendorExists(tblVendor.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Type"] = new SelectList(_context.TblVendorType, "Id", "Id", tblVendor.Type); return(View(tblVendor)); }
public static bool Insert(int OwnerID, string CompanyName, string CompanyEmail, DateTime InspectionDate, string Bio, string Website) { try { using (RoundTheCornerEntities rc = new RoundTheCornerEntities()) { PL.TblVendor newRow = new TblVendor() { VendorID = rc.TblVendors.Any() ? rc.TblVendors.Max(v => v.VendorID) + 1 : 1, OwnerID = OwnerID, CompanyName = CompanyName, CompanyEmail = CompanyEmail, InspectionDate = InspectionDate, Bio = Bio, Website = Website, Confirmed = false }; rc.TblVendors.Add(newRow); rc.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }
public static bool Insert(VendorModel vendor) { try { using (RoundTheCornerEntities rc = new RoundTheCornerEntities()) { PL.TblVendor newRow = new TblVendor() { VendorID = rc.TblVendors.Any() ? rc.TblVendors.Max(v => v.VendorID) + 1 : 1, OwnerID = vendor.OwnerID, CompanyName = vendor.CompanyName, CompanyEmail = vendor.CompanyEmail, LicenseNumber = vendor.LicenseNumber, InspectionDate = vendor.InspectionDate, Bio = vendor.Bio, Website = vendor.Website, Confirmed = false }; rc.TblVendors.Add(newRow); rc.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Create([Bind("AutoId,Id,Name,ContactPerson,ContactNo,PhoneNo,VendorType,Type,Place,Dob,Gstno,Tinno,Panno,Cinno,AdhaarNo,OpeningBalance,OpeningBalanceType,OpeningBalanceDate,CreditLimit,CreditPeriod,CreditInterestRate,DebitInterestRate,CreatedDatetime,Photo,Remark,SuretyPerson,SuretyPersonContactNo,SuretyPersonAddress")] TblVendor tblVendor) { if (ModelState.IsValid) { var saved = false; using (var transaction = _context.Database.BeginTransaction()) { try { _context.Add(tblVendor); if (tblVendor.VendorType == "Customer") { _context.UpdateNextSequence(SequenceTable.tbl_Customer); } else if (tblVendor.VendorType == "Supplier") { _context.UpdateNextSequence(SequenceTable.tbl_Supplier); } else { _context.UpdateNextSequence(SequenceTable.tbl_vendor); } await _context.SaveChangesAsync(); saved = true; } catch (Exception e) { throw new InvalidOperationException(e.Message); } finally { if (saved) { transaction.Commit(); } } } return(RedirectToAction(nameof(Index))); } ViewData["Type"] = new SelectList(_context.TblVendorType, "Id", "Id", tblVendor.Type); return(View(tblVendor)); }
public static bool Update(VendorModel vendor) { try { if (vendor.VendorID != 0) { using (RoundTheCornerEntities rc = new RoundTheCornerEntities()) { TblVendor tblVendor = rc.TblVendors.FirstOrDefault(v => v.VendorID == vendor.VendorID); if (tblVendor != null) { tblVendor.VendorID = vendor.VendorID; tblVendor.OwnerID = vendor.OwnerID; tblVendor.CompanyName = vendor.CompanyName; tblVendor.CompanyEmail = vendor.CompanyEmail; tblVendor.LicenseNumber = vendor.LicenseNumber; tblVendor.InspectionDate = vendor.InspectionDate; tblVendor.Bio = vendor.Bio; tblVendor.Website = vendor.Website; tblVendor.Confirmed = vendor.Confirmed; rc.SaveChanges(); return(true); } else { throw new Exception("Vendor was not found"); } } } else { throw new Exception("Must have a valid id"); } } catch (Exception ex) { throw ex; } }
public IActionResult editVendor(TblVendor tv) { ourdbCntxt.TblVendor.Update(tv); ourdbCntxt.SaveChanges(); return(RedirectToAction(nameof(VendorsController.viewAllVendors))); }
public IActionResult vendorDetails(int vNum) { TblVendor tv = ourdbCntxt.TblVendor.Where(abc => abc.VendorId == vNum).FirstOrDefault <TblVendor>(); return(View(tv)); }