public async Task <ProjectResult> Imeinoupdate(tblAgent model) { try { if (ModelState.IsValid) { tblAgent _objcr = new tblAgent(); _objcr = _db.tblAgents.Where(a => a.AgentName == model.AgentName && a.OperatorCode == model.OperatorCode).FirstOrDefault(); _objcr.IMEINo = model.IMEINo; _db.Entry(_objcr).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); return(new ProjectResult { Message = "Success", Status = 1, Response = _objcr }); } else { return(new ProjectResult { Message = "Failed", Status = 0, Response = null }); } } catch (Exception exp) { return(new ProjectResult { Message = exp.ToString(), Status = 0, Response = null }); } }
public bool UpdateAgent(AgentVM agentVM) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblAgent agent = unitOfWork.TblAgentRepository.GetByID(agentVM.AgentID); agent.CompID = agentVM.CompanyID; agent.AgentName = agentVM.AgentName; agent.Address1 = agentVM.Address1; agent.Address2 = agentVM.Address2; agent.Address3 = agentVM.Address3; agent.RateValue = agentVM.RateValue; agent.ModifiedDate = DateTime.Now; agent.ModifiedBy = agentVM.ModifiedBy; agent.AgentType = agentVM.AgentType; agent.AgentNIC = agentVM.AgentNIC; agent.AgentBRNo = agentVM.AgentBR; agent.AgentCode = agentVM.AgentCode; unitOfWork.TblAgentRepository.Update(agent); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }
public async Task <ProjectResult> AgentLogin(tblAgent model) { try { var result = _db.tblAgents.Where(a => a.AgentName == model.AgentName && a.Password == model.Password && a.OperatorCode == model.OperatorCode && a.IMEINo == model.IMEINo).ToList(); if (result.Count != 0) { return(new ProjectResult { Message = "Success", Status = 1, Response = result }); } else { return(new ProjectResult { Message = "Not Success", Status = 0, Response = null }); } } catch (Exception exp) { return(new ProjectResult { Message = exp.ToString(), Status = 0, Response = null }); } }
public ActionResult DeleteConfirmed(int id) { tblAgent tblAgent = db.tblAgent.Find(id); db.tblAgent.Remove(tblAgent); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Details(int id = 0) { tblAgent tblagent = db.tblAgents.Find(id); if (tblagent == null) { return(HttpNotFound()); } return(View(tblagent)); }
public ActionResult Edit([Bind(Include = "ID,Name,Email,Color")] tblAgent tblAgent) { if (ModelState.IsValid) { db.Entry(tblAgent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblAgent)); }
public ActionResult Create([Bind(Include = "ID,Name,Email,Color")] tblAgent tblAgent) { if (ModelState.IsValid) { db.tblAgent.Add(tblAgent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblAgent)); }
// GET: Agents/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblAgent tblAgent = db.tblAgent.Find(id); if (tblAgent == null) { return(HttpNotFound()); } return(View(tblAgent)); }
public bool DeleteAgent(int agentID) { using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction()) { try { tblAgent agent = unitOfWork.TblAgentRepository.GetByID(agentID); unitOfWork.TblAgentRepository.Delete(agent); unitOfWork.Save(); //Complete the Transaction dbTransaction.Commit(); return(true); } catch (Exception ex) { //Roll back the Transaction dbTransaction.Rollback(); return(false); } } }
public async Task <ProjectResult> AgentRegistration(tblAgent model) { tblAgent _objAgent = new tblAgent(); try { if (ModelState.IsValid) { _objAgent.AgentId = model.AgentId; _objAgent.AgentName = model.AgentName; _objAgent.Password = model.Password; _objAgent.IMEINo = model.IMEINo; _objAgent.OperatorCode = model.OperatorCode; _db.tblAgents.Add(_objAgent); _db.SaveChanges(); return(new ProjectResult { Message = "Success", Status = 1, Response = "Success" }); } else { return(new ProjectResult { Message = "Failed", Status = 0, Response = null }); } } catch (Exception exp) { return(new ProjectResult { Message = exp.ToString(), Status = 0, Response = null }); } }