public bool UpdateLocation(FA_Location location) { string sql = " Update FA_Location set LocationName=@LocationName,OrganizationId=@OrganizationId," + " LastUpdatedBy=@LastUpdatedBy,LastUpdatedDate=@LastUpdatedDate,LocationCode =@LocationCode" + " where LocationId=@LocationId"; using (var db = DbHelper.GetDBConnection()) { using (var trsn = new TransactionScope()) { //db.Execute(sql); var lst = db.Execute(sql, location); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
public bool InsertLocation(FA_Location location) { string sql = " Insert into FA_Location (LocationName,OrganizationId,EnteredBy,EnteredDate," + " LastUpdatedBy,LastUpdatedDate,IsDeleted,DeletedDate,DeletedBy,LocationCode) " + " values " + "(@LocationName,@OrganizationId,@EnteredBy,@EnteredDate," + "0,null,0,null,0,@LocationCode)"; using (var db = DbHelper.GetDBConnection()) { using (var trsn = new TransactionScope()) { //db.Execute(sql); var lst = db.Execute(sql, location); trsn.Complete(); db.Close(); if (lst > 0) { return(true); } else { return(false); } } } }
// GET: Location/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } FA_Location location = db.GetLocationById((int)id); if (location == null) { return(HttpNotFound()); } //ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name", location.OrganizationId); return(View(location)); }
public ActionResult Edit(FormCollection frm) { var ses = sesrepo.GetSessionById((User as CustomPrincipal).UserId); int orgid = ses.OrganizationId; FA_Location location = db.GetLocationById(Convert.ToInt32(frm["LocationId"])); location.LocationName = frm["LocationName"]; location.LocationCode = frm["LocationCode"]; location.OrganizationId = orgid;// Convert.ToInt32(frm["OrganizationId"]); location.LastUpdatedBy = (User as CustomPrincipal).UserId; location.LastUpdatedDate = DateTime.Now; if (ModelState.IsValid) { db.UpdateLocation(location); return(RedirectToAction("Index")); } return(View(location)); }
public ActionResult Create(FormCollection frm) { var ses = sesrepo.GetSessionById((User as CustomPrincipal).UserId); int orgid = ses.OrganizationId; FA_Location location = new FA_Location(); location.LocationName = frm["LocationName"]; location.LocationCode = frm["LocationCode"]; location.OrganizationId = orgid;// Convert.ToInt32(frm["OrganizationId"]); location.EnteredBy = (User as CustomPrincipal).UserId; location.EnteredDate = DateTime.Now; if (ModelState.IsValid) { db.InsertLocation(location); return(RedirectToAction("Index")); } //ViewBag.OrganizationId = new SelectList(ddl.GetOrganizationList(), "Id", "Name", location.OrganizationId); return(View(location)); }