public void UpdateCard(CustomerIsssueCard model) { Core_Customers comm = entities.Core_Customers.Where(u => u.CustomerID == model.CustomerID).FirstOrDefault(); comm.ProductId = model.ProductId; comm.AgentId = model.AgentId; comm.CustomerCode = model.CustomerCode; comm.FirstName = model.FirstName; comm.MiddleName = model.MiddleName; comm.LastName = model.LastName; comm.Gender = model.Gender; comm.DateOfBirth = model.DateOfBirth; comm.Address1 = model.Address1; comm.Address2 = model.Address2; comm.HouseNo = model.HouseNo; comm.City = model.City; comm.ZipCode = model.ZipCode; comm.CountryID = model.CountryID; comm.HomePhone = model.HomePhone; comm.WorkPhone = model.WorkPhone; comm.MobileNo = model.MobileNo; comm.FaxNo = model.FaxNo; comm.Email = model.Email; comm.Profession = model.Profession; comm.CustomerTypeId = model.CustomerTypeId; comm.CustomerStatus = model.CustomerStatus; comm.Created = DateTime.Now; comm.CreatedBy = model.CreatedBy; comm.Updated = DateTime.Now; comm.UpdatedBy = model.UpdatedBy; entities.ApplyCurrentValues(comm.EntityKey.EntitySetName, comm); entities.SaveChanges(); ///// }
public long CreateCard(CustomerIsssueCard model) { Core_Customers obj = new Core_Customers { ProductId = model.ProductId, AgentId = model.AgentId, CustomerCode = model.CustomerCode, FirstName = model.FirstName, MiddleName = model.MiddleName, LastName = model.LastName, Gender = model.Gender, DateOfBirth = model.DateOfBirth, Address1 = model.Address1, Address2 = model.Address2, HouseNo = model.HouseNo, City = model.City, ZipCode = model.ZipCode, CountryID = model.CountryID, HomePhone = model.HomePhone, WorkPhone = model.WorkPhone, MobileNo = model.MobileNo, FaxNo = model.FaxNo, Email = model.Email, Profession = model.Profession, CustomerTypeId = model.CustomerTypeId, CustomerStatus = model.CustomerStatus, //Created = model.Created, //CreatedBy = model.CreatedBy, }; entities.AddToCore_Customers(obj); entities.SaveChanges(); return(entities.Core_Customers.Max(x => x.CustomerID)); }
public void UpdateCards(CustomerIsssueCard model) { Htl_CustomerCards comm = entities.Htl_CustomerCards.Where(u => u.CustomerCardsId == model.CustomerCardsId).FirstOrDefault(); comm.CardId = model.CardId; comm.AgentId = model.AgentId; comm.CustomerId = Convert.ToInt16(model.CustomerID); comm.CreateDate = model.Created; comm.CreatedBy = model.CreatedBy; comm.UpdatedBy = model.UpdatedBy; comm.UpdatedDate = model.Updated; entities.ApplyCurrentValues(comm.EntityKey.EntitySetName, comm); entities.SaveChanges(); }
public void CreateCards(CustomerIsssueCard model) { Htl_CustomerCards obj = new Htl_CustomerCards { //CardId = model.CustomerCardId.ElementAt(0), CardId = model.CardId, AgentId = model.AgentId, CustomerId = Convert.ToInt16(model.CustomerID), CreateDate = DateTime.Now, CreatedBy = model.CreatedBy, }; entities.AddToHtl_CustomerCards(obj); entities.SaveChanges(); }
// // GET: /CustomerCard/Create public ActionResult Create(AgentCardViewModel model, string[] Selectedcardnumber, int AgentId) { List <SelectListItem> customerstatus = new List <SelectListItem>(); customerstatus.Add(new SelectListItem { Text = "Active", Value = "T" }); customerstatus.Add(new SelectListItem { Text = "InActive", Value = "F" }); TempData["AgentName"] = _issuecardrepo.GetAgentInfo(AgentId); // ViewData["CustomerStatus"] = new SelectList(customerstatus, "Value", "Text",0); //ViewData["Agents"] = new SelectList(_issuecardrepo.ListAllAgent(), "AgentId", "AgentName", 0); // ViewData["Country"] = new SelectList(_CountryRepo.HotelCountryList(), "CountryId", "CountryName"); //ViewData["CustomerType"] = new SelectList(_Custrepo.GetCustomerType(), "CustomerTypeId", "CustomerTypeName"); List <string> Selectedcardnumbers = new List <string>(); List <int> SelectedcardIDs = new List <int>(); foreach (string sid in Selectedcardnumber) { Selectedcardnumbers.Add(sid); int cardid = _Custrepo.GetCardIdByCardNumber(sid); SelectedcardIDs.Add(cardid); } var viewmodel = new CustomerIsssueCard { CustomerStatusList = customerstatus, CustomerCard = Selectedcardnumbers, CustomerCardId = SelectedcardIDs, CountryList = _CountryRepo.GetAllCountryList().ToList(), AgentList = _issuecardrepo.GetAllAgentList().ToList(), CustomerTypeList = _Custrepo.GetAllCustomerType() // AgentId =id }; // TempData["AgentName"] = _issuecardrepo.GetAgentInfo(Agent.AgentId); return(View(viewmodel)); }
//[HttpPost] //public JsonResult FindCustomerInfo(string searchText, int maxResult) //{ // var result = GetCustomerInfo(searchText, maxResult); // return Json(result); //} //public List<Core_Customers> GetCustomerInfo(string CustomerCode, int maxResult) //{ // return _Custrepo.GetAddedCustomer(CustomerCode, maxResult).ToList(); //} // List For Selelcted array of Cards public void Add(List <int> idlist, int agentid, long CustomerId) { try { int count = idlist.Count; List <CustomerIsssueCard> Lists = new List <CustomerIsssueCard>(); for (int i = 0; i < count; i++) { CustomerIsssueCard CustomerCardList = new CustomerIsssueCard(); CustomerCardList.AgentId = agentid; CustomerCardList.CustomerID = CustomerId; CustomerCardList.CardId = idlist[i]; Lists.Add(CustomerCardList); } _Custrepo.SaveCustomerCard(Lists); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Create(CustomerIsssueCard model, List <int> CardsId) { var ts = (TravelSession)Session["TravelSessionInfo"]; for (int i = 0; i < CardsId.Count; i++) { model.CardId = CardsId[i]; //model.CreatedBy = ts.AppUserId; model.CustomerID = model.HFCustomerID; } //model.CreatedBy = ts.AppUserId; model.Created = DateTime.Now; model.ProductId = 2; //model.CustomerTypeId =1; model.CustomerTpeName = _GenPro.GetCustomerType(model.CustomerTypeId); model.AgentId = 2; model.Gender = "male"; //long CustomerID = _Custrepo.GetCustomerID(); bool flag; flag = _Custrepo.CheckDuplicateUsername(model.CustomerCode); if (flag == true) { //_Custrepo.UpdateCard(model); long CID = _Custrepo.CreateCard(model); model.CustomerID = CID; _Custrepo.CreateCards(model); } else { model.AgentId = 2; model.Gender = "male"; model.CustomerID = _Custrepo.GetCustomerID(); model.ProductId = 2; model.UpdatedBy = ts.AppUserId; //_Custrepo.CreateCard(model); _Custrepo.UpdateCard(model); _Custrepo.CreateCards(model); } CardViewModel cardmodel = new CardViewModel(); cardmodel.CardId = model.CardId; cardmodel.CardStatusId = 3; _Custrepo.UpdateCardToActiveStatus(cardmodel); //// This IS for Active Status //if (Selectedcardnumber != null) ////////// Checking if product is other than Ticketing //{ // List<int> Selectedcardnumbers = new List<int>(); // foreach (int sid in Selectedcardnumber) // { // Selectedcardnumbers.Add(sid); // } // Add(Selectedcardnumbers,model.AgentId ,CustomerID); // } //////////// Return view ////////////// //ViewData["Country"] = new SelectList(_CountryRepo.HotelCountryList(), "CountryId", "CountryName"); CustomerIsssueCard models = new CustomerIsssueCard() { CountryList = _CountryRepo.GetAllCountryList().ToList(), }; //ViewData["Agents"] = new SelectList(_issuecardrepo.ListAllAgent(), "AgentId", "AgentName", 0); ViewData["success"] = "Record successfully added."; return(RedirectToAction("Index", models)); }