public Int32 postCustomer() { try { Data.MstCustomer newCustomer = new Data.MstCustomer(); newCustomer.Customer = "n/a"; newCustomer.Address = "n/a"; newCustomer.ContactPerson = "n/a"; newCustomer.ContactNumber = "n/a"; newCustomer.CreditLimit = 0; newCustomer.TermId = TermId(); newCustomer.TIN = "n/a"; newCustomer.WithReward = false; newCustomer.RewardNumber = "n/a"; newCustomer.RewardConversion = 0; newCustomer.AccountId = AccountId(); newCustomer.EntryUserId = UserId(); newCustomer.EntryDateTime = DateTime.Today; newCustomer.UpdateUserId = UserId(); newCustomer.UpdateDateTime = DateTime.Today; newCustomer.IsLocked = false; db.MstCustomers.InsertOnSubmit(newCustomer); db.SubmitChanges(); return(newCustomer.Id); } catch (Exception e) { return(0); } }
public HttpResponseMessage SaveCustomer(ApiModels.MstCustomerModel objCustomer) { try { var currentUser = from d in db.MstUsers where d.AspNetUserId == User.Identity.GetUserId() select d; Data.MstCustomer newCustomer = new Data.MstCustomer() { FullName = objCustomer.FullName, BirthDate = Convert.ToDateTime(objCustomer.BirthDate), Gender = objCustomer.Gender, Address = objCustomer.Address, ContactNumber = objCustomer.ContactNumber, Photo = "NA", UserId = null, IsLocked = true, CreatedByUserId = currentUser.FirstOrDefault().Id, CreatedDateTime = DateTime.Now, UpdatedByUserId = currentUser.FirstOrDefault().Id, UpdatedDateTime = DateTime.Now }; db.MstCustomers.InsertOnSubmit(newCustomer); db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public Int32 postCustomer(Entities.MstCustomer customer) { try { var term = from d in db.MstTerms select d; var account = from d in db.MstAccounts select d; var userId = (from d in db.MstUsers where d.AspNetUserId == User.Identity.GetUserId() select d).FirstOrDefault().Id; Data.MstCustomer newCustomer = new Data.MstCustomer(); newCustomer.Customer = "n/a"; newCustomer.Address = "n/a"; newCustomer.ContactPerson = "n/a"; newCustomer.ContactNumber = "n/a"; newCustomer.CreditLimit = 0; newCustomer.TermId = term.Select(m => m.Id).FirstOrDefault(); newCustomer.TIN = "n/a"; newCustomer.WithReward = false; newCustomer.RewardNumber = "n/a"; newCustomer.RewardConversion = 0; newCustomer.AccountId = account.Select(m => m.Id).FirstOrDefault(); newCustomer.EntryUserId = userId; newCustomer.EntryDateTime = DateTime.Today; newCustomer.UpdateUserId = userId; newCustomer.UpdateDateTime = DateTime.Today; newCustomer.IsLocked = false; db.MstCustomers.InsertOnSubmit(newCustomer); db.SubmitChanges(); return(newCustomer.Id); } catch (Exception e) { Debug.WriteLine(e); return(0); } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName, Email = "" }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); String fullname = model.LastName + ", " + model.FirstName + " " + model.MiddleName; Data.lendingsystemDataContext db = new Data.lendingsystemDataContext(); Data.MstUser newUser = new Data.MstUser() { AspNetUserId = user.Id, Username = model.UserName, Password = model.Password, FullName = fullname, IsLocked = true, UserType = "Customer" }; db.MstUsers.InsertOnSubmit(newUser); db.SubmitChanges(); Data.MstCustomer newCustomer = new Data.MstCustomer() { FullName = fullname, BirthDate = Convert.ToDateTime(model.BirthDate), Gender = model.Gender, Address = model.Address, ContactNumber = model.ContactNumber, Photo = "NA", UserId = newUser.Id, IsLocked = true, CreatedByUserId = newUser.Id, CreatedDateTime = DateTime.Now, UpdatedByUserId = newUser.Id, UpdatedDateTime = DateTime.Now }; db.MstCustomers.InsertOnSubmit(newCustomer); db.SubmitChanges(); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public Int32 PostMstCustomer(MstCustomer customer) { try { var currentUser = from d in db.MstUsers where d.AspNetId == User.Identity.GetUserId() select d; if (currentUser.Any()) { string customerCode = "0001"; var customers = from d in db.MstCustomers.OrderByDescending(d => d.Id) select d; if (customers.Any()) { Int32 nextCustomerCode = Convert.ToInt32(customers.FirstOrDefault().CustomerCode) + 1; customerCode = padNumWithZero(nextCustomerCode, 4); } Data.MstCustomer newMstCustomer = new Data.MstCustomer() { CustomerCode = customerCode, LastName = customer.LastName, FirstName = customer.FirstName, MiddleName = customer.MiddleName, CivilStatus = customer.CivilStatus, Gender = customer.Gender, BirthDate = Convert.ToDateTime(customer.BirthDate), Citizen = customer.Citizen, TIN = customer.TIN, IdType = customer.IdType, IdNumber = customer.IdNumber, Address = customer.Address, City = customer.City, Province = customer.Province, Country = customer.Country, ZipCode = customer.ZipCode, EmailAddress = customer.EmailAddress, TelephoneNumber = customer.TelephoneNumber, MobileNumber = customer.MobileNumber, Employer = customer.Employer, EmployerIndustry = customer.EmployerIndustry, NoOfYearsEmployed = customer.NoOfYearsEmployed, Position = customer.Position, EmploymentStatus = customer.EmploymentStatus, EmployerAddress = customer.EmployerAddress, EmployerCity = customer.EmployerCity, EmployerProvince = customer.EmployerProvince, EmployerCountry = customer.EmployerCountry, EmployerZipCode = customer.EmployerZipCode, EmployerTelephoneNumber = customer.EmployerTelephoneNumber, EmployerMobileNumber = customer.EmployerMobileNumber, SpouseLastName = customer.SpouseLastName, SpouseFirstName = customer.SpouseFirstName, SpouseMiddleName = customer.SpouseMiddleName, SpouseBirthDate = Convert.ToDateTime(customer.SpouseBirthDate), SpouseCitizen = customer.SpouseCitizen, SpouseEmployer = customer.SpouseEmployer, SpouseTIN = customer.SpouseTIN, Remarks = customer.Remarks, Status = customer.Status, Picture = customer.Picture, Attachment1 = customer.Attachment1, Attachment2 = customer.Attachment2, Attachment3 = customer.Attachment3, Attachment4 = customer.Attachment4, Attachment5 = customer.Attachment5, IsLocked = customer.IsLocked, CreatedBy = currentUser.FirstOrDefault().Id, CreatedDateTime = DateTime.Now, UpdatedBy = currentUser.FirstOrDefault().Id, UpdatedDateTime = DateTime.Now, BusinessName = customer.BusinessName, BusinessAddress = customer.BusinessAddress, BusinessType = customer.BusinessType, BusinessPosition = customer.BusinessPosition }; db.MstCustomers.InsertOnSubmit(newMstCustomer); db.SubmitChanges(); return(newMstCustomer.Id); } else { return(0); } } catch (Exception e) { Debug.WriteLine(e); return(0); } }