public ActionResult Details(long?id) { Models.UserDetailModel details = null; CLayer.User data = BLayer.User.Get(id.Value); if (data != null) { details = new Models.UserDetailModel() { UserId = data.UserId, SalutationId = data.SalutationId, FirstName = data.FirstName, LastName = data.LastName, DateOfBirth = data.DateOfBirth.ToShortDateString(), Status = data.Status, Email = data.Email, CreatedDate = data.CreatedDate, DeletedDate = data.DeletedDate, LastLoginOn = data.LastLoginOn, Phone = data.Phone, Mobile = data.Mobile, PANNo = data.PANNo }; } CLayer.B2B b2b = BLayer.B2B.Get(id.Value); if (b2b != null) { details.MaxStaff = b2b.MaximumStaff; details.Name = b2b.Name; details.PANNo = b2b.PANNo; } CLayer.Address adrs = BLayer.Address.GetPrimaryOnUser(id.Value); if (adrs != null) { details.Address = adrs.AddressText; details.AddressId = adrs.AddressId; details.State = adrs.State; details.CountryId = adrs.CountryId; details.Phone = adrs.Phone; details.Mobile = adrs.Mobile; details.ZipCode = adrs.ZipCode; details.CityId = adrs.CityId; details.City = adrs.City; if (adrs.CityId > 0) { details.City = BLayer.City.Get(adrs.CityId).Name; details.CityId = adrs.CityId; } else { if (adrs.City != null && adrs.City != "") { details.City = adrs.City; } } details.LoadPlaces(); } return(View(details)); }
public ActionResult SupplierUpdate(Models.UserDetailModel data) { CLayer.User usr = new CLayer.User() { UserId = data.UserId, Businessname = data.Name, //Businessname SalutationId = data.SalutationId, FirstName = data.FirstName, LastName = data.FirstName, Email = data.Email }; BLayer.User.Update(usr); CLayer.B2B b2b = new CLayer.B2B() { B2BId = data.UserId, Name = data.Name, //Businessname PropertyDescription = data.PropertyDescription, AvailableProperties = data.AvailableProperties }; BLayer.B2B.Update(b2b); //if (data.UserId > 0) //{ // ViewData["B2BId"] = data.UserId; //} CLayer.Address adrs = new CLayer.Address() { AddressId = data.AddressId, UserId = data.UserId, AddressText = data.Address, //CityId = data.CityId, State = data.State, CountryId = data.CountryId, Phone = data.Phone, ZipCode = data.ZipCode, Mobile = data.Mobile, AddressType = (int)CLayer.Address.AddressTypes.Primary }; if (data.CityId > 0) { adrs.City = BLayer.City.Get(data.CityId).Name; adrs.CityId = data.CityId; } else { if (data.City != null && data.City != "") { adrs.City = data.City; } } BLayer.Address.Save(adrs); ViewBag.Message = "Your details updated successfully"; return(RedirectToAction("SupplierDetails", new { id = data.UserId })); }
public async Task VerifyUserUpdateCalledOnce() { // Arrange var mockRepository = new Mock <IUserDetailsRepository>(); var userManger = new UserManager(mockRepository.Object); var taskDetail = new Models.UserDetailModel(); // Act await userManger.UpdateUserDetails(10, taskDetail); // Assert mockRepository.Verify(t => t.Update(10, taskDetail), Times.Once); }
public async Task Verify_User_Put_Returns_BadRequest_WhenuserDetailIsInvalid() { // Arrange var mockManageUser = new Mock <IUserManager>(); var userRepository = new UserController(mockManageUser.Object, Logger); var userDetail = new Models.UserDetailModel() { UserId = 1001, EmployeeId = 10 }; // Act var statusResult = await userRepository.Put(1002, userDetail); // Assert Assert.NotNull(statusResult as BadRequestObjectResult); Assert.Equal("Invalid user to edit", (statusResult as BadRequestObjectResult).Value); }
public async Task Verify_User_Post_Returns_InternalServerErrorStatus_OnException() { // Arrange var mockManageUser = new Mock <IUserManager>(); var userRepository = new UserController(mockManageUser.Object, Logger); var userDetail = new Models.UserDetailModel() { UserId = 1001, EmployeeId = 10 }; mockManageUser.Setup(manage => manage.AddUserDetails(userDetail)).Throws(new Exception()); // Act var statusResult = await userRepository.Post(userDetail); // Assert Assert.Equal((int)HttpStatusCode.InternalServerError, (statusResult as ObjectResult)?.StatusCode); }
public ActionResult AllowCBookSamedaybook(Models.UserDetailModel data) { try { CLayer.B2B book = new CLayer.B2B() { IsCorpBookingtoday = data.IsCorpBookingtoday, UserId = data.UserId }; long id = BLayer.B2B.AllowCBookSamedaybook(book.IsCorpBookingtoday, book.UserId); return(null); } catch (Exception ex) { Common.LogHandler.HandleError(ex); return(Redirect("~/Admin/ErrorPage")); // } }
public ActionResult Pager(Models.TransactionsModel data) { Models.UserDetailModel Ud = new Models.UserDetailModel(); long id = Ud.UserId; List <CLayer.Booking> users = BLayer.Transaction.GetUserId(id, (data.currentPage - 1) * data.Limit, data.Limit); ViewBag.Filter = new Models.TransactionsModel(); Models.TransactionsModel forPager = new Models.TransactionsModel() { TotalRows = 0, Limit = 25, currentPage = data.currentPage }; if (users.Count > 0) { forPager.TotalRows = users[0].TotalRows; } ViewBag.Filter = forPager; return(PartialView("~/Areas/Admin/Views/Common/_TransactionList.cshtml", users)); }
public ActionResult SaveCBookCredit(Models.UserDetailModel data) { try { CLayer.B2B payment = new CLayer.B2B() { IsCreditBooking = data.IsCreditBooking, CreditDays = data.CreditDays, CreditAmount = data.CreditAmount, TotalCreditAmount = data.CreditAmount, UserId = data.UserId }; long id = BLayer.B2B.SaveCBookCredit(payment); return(null); } catch (Exception ex) { Common.LogHandler.HandleError(ex); return(Redirect("~/Admin/ErrorPage")); // } }
public async Task Verify_User_Put_Return_OkStatusAndCheckServiceResponse() { // Arrange var mockManageUser = new Mock <IUserManager>(); var userRepository = new UserController(mockManageUser.Object, Logger); var userDetail = new Models.UserDetailModel() { UserId = 1001, EmployeeId = 10 }; mockManageUser.Setup(manage => manage.IsUserValid(userDetail)).Returns(true); mockManageUser.Setup(manage => manage.UpdateUserDetails(1001, userDetail)).Returns(Task.FromResult(1001)); // Act var statusResult = await userRepository.Put(1001, userDetail); // Assert Assert.NotNull(statusResult as OkObjectResult); Assert.Equal(1001, (statusResult as OkObjectResult).Value); }
public async Task VerifyAddUserDetails_Returns_OkStatusAndCheckTaskId() { // Arrange var mockManageUser = new Mock <IUserManager>(); var userRepository = new UserController(mockManageUser.Object, Logger); var userDetail = new Models.UserDetailModel() { UserId = 1001, EmployeeId = 10 }; mockManageUser.Setup(manage => manage.AddUserDetails(userDetail)).Returns(Task.FromResult(1001)); // Act var statusResult = await userRepository.Post(userDetail); // Assert Assert.NotNull(statusResult as OkObjectResult); Assert.Equal(1001, (statusResult as OkObjectResult).Value); }
public void SaveGST(Models.UserDetailModel model, int CustID) { long custgststeid = 0; try { CLayer.OfflineBooking data = new CLayer.OfflineBooking(); data.SubCustomerAddress = model.SubCustomerAddress; data.SubCustomerCity = model.SubCustomerCity; data.SubCustomerCityname = model.SubCustomerCityname; data.SubCustomerpinCode = model.SubCustomerpinCode; data.SubCustomerGstRegNo = model.GSTRegistrationNo; data.SubCustomerGstStateId = Convert.ToInt32(model.StateOfRegistration); data.SubCustomerid = CustID; data.CustomerTableType = 1; data.OffGSTId = model.B2bGSTId; BLayer.User.SaveGST(data); } catch (Exception ex) { Common.LogHandler.HandleError(ex); } }
public async Task VerifyGetUserDetail_Return_OkStatusAndUserDetails() { // Arrange var mockManageUser = new Mock <IUserManager>(); var userRepository = new UserController(mockManageUser.Object, Logger); var userDetail = new Models.UserDetailModel() { UserId = 1, EmployeeId = 10 }; mockManageUser.Setup(manage => manage.GetUserDetail(1)).Returns(Task.FromResult(userDetail)); // Act var statusResult = await userRepository.GetUserById(1); // Assert Assert.NotNull(statusResult as OkObjectResult); var userDetailsResult = (statusResult as OkObjectResult).Value as Models.UserDetailModel; Assert.Equal(1, userDetailsResult?.UserId); Assert.Equal(10, userDetailsResult?.EmployeeId); }
public ActionResult CorporateDetails(long id) { Models.UserDetailModel details = null; CLayer.User data = BLayer.User.Get(id); if (data != null) { // details.FullName = data.FirstName + data.LastName; details = new Models.UserDetailModel() { UserId = data.UserId, SalutationId = data.SalutationId, FirstName = data.FirstName, LastName = data.LastName, DateOfBirth = data.DateOfBirth.ToShortDateString(), Status = data.Status, Email = data.Email, CreatedDate = data.CreatedDate, DeletedDate = data.DeletedDate, LastLoginOn = data.LastLoginOn }; } CLayer.B2B b2b = BLayer.B2B.Get(id); if (b2b != null) { details.MaxStaff = b2b.MaximumStaff; details.Name = b2b.Name; details.RequestStatus = b2b.RequestStatus; } //if (id > 0) //{ // ViewData["B2BId"] = id; //} if (b2b.RequestStatus == (int)CLayer.ObjectStatus.StatusType.NotVerified || b2b.RequestStatus == (int)CLayer.ObjectStatus.StatusType.Unread) { BLayer.B2B.SetStatus(id, (int)CLayer.ObjectStatus.StatusType.Read); } CLayer.Address adrs = BLayer.Address.GetPrimaryOnUser(id); if (adrs != null) { details.Address = adrs.AddressText; details.AddressId = adrs.AddressId; details.State = adrs.State; details.CountryId = adrs.CountryId; details.Phone = adrs.Phone; details.Mobile = adrs.Mobile; details.ZipCode = adrs.ZipCode; if (adrs.CityId > 0) { details.City = BLayer.City.Get(adrs.CityId).Name; details.CityId = adrs.CityId; } else { if (adrs.City != null && adrs.City != "") { details.City = adrs.City; } } } CLayer.Address BillingAddress = BLayer.Address.GetBillingAddress(id); if (BillingAddress != null) { details.BillingAddressType = BillingAddress.BillingAddressType; details.BillingAddressId = BillingAddress.BillingAddressId; details.BillingAddress = BillingAddress.BillingAddress; details.BillingCityId = BillingAddress.BillingCityId; details.BillingState = BillingAddress.BillingState; details.BillingCity = BillingAddress.BillingCity; details.BillingCountryId = BillingAddress.BillingCountryId; details.BillingZipCode = BillingAddress.BillingZipCode; details.IsClicked = false; } else { details.BillingAddress = details.Address; details.BillingAddressId = 0; details.BillingAddress = details.Address; details.BillingCityId = details.CityId; details.BillingCity = details.City; details.BillingState = details.State; details.BillingCountryId = details.CountryId; details.Phone = details.Phone; details.Mobile = details.Mobile; details.BillingAddressType = (int)CLayer.Address.AddressTypes.Primary; details.BillingZipCode = details.ZipCode; details.IsClicked = true; } if (details.BillingZipCode == details.ZipCode && details.BillingAddress == details.Address && details.BillingCityId == details.CityId && details.BillingCity == details.City && details.BillingState == details.State && details.BillingCountryId == details.CountryId) { details.IsClicked = true; } details.LoadPlaces(); return(View(details)); }
public ActionResult AffiliateDetails(long?id) { Models.UserDetailModel details = null; CLayer.User data = BLayer.User.Get(id.Value); if (data != null) { details = new Models.UserDetailModel() { UserId = data.UserId, SalutationId = data.SalutationId, FirstName = data.FirstName, LastName = data.LastName, DateOfBirth = data.DateOfBirth.ToShortDateString(), Status = data.Status, Email = data.Email, CreatedDate = data.CreatedDate, DeletedDate = data.DeletedDate, LastLoginOn = data.LastLoginOn, Phone = data.Phone, Mobile = data.Mobile, PANNo = data.PANNo }; } //if (id > 0) //{ // ViewData["B2BId"] = id; //} CLayer.B2B b2b = BLayer.B2B.Get(id.Value); if (b2b != null) { details.MaxStaff = b2b.MaximumStaff; details.Name = b2b.Name; details.PANNo = b2b.PANNo; details.RequestStatus = b2b.RequestStatus; details.PropertyDescription = b2b.PropertyDescription; details.AvailableProperties = b2b.AvailableProperties; } CLayer.Address adrs = BLayer.Address.GetPrimaryOnUser(id.Value); if (adrs != null) { details.Address = adrs.AddressText; details.AddressId = adrs.AddressId; details.State = adrs.State; details.CountryId = adrs.CountryId; details.Phone = adrs.Phone; details.Mobile = adrs.Mobile; details.ZipCode = adrs.ZipCode; if (adrs.CityId > 0) { details.City = BLayer.City.Get(adrs.CityId).Name; details.CityId = adrs.CityId; } else { if (adrs.City != null && adrs.City != "") { details.City = adrs.City; } } details.LoadPlaces(); } List <CLayer.B2B> SupplierList = new List <CLayer.B2B>(); SupplierList = BLayer.B2B.GetAllSupplier(id.Value); details.SupplierList = SupplierList; return(View(details)); }
public ActionResult Update(Models.UserDetailModel data) { if (ModelState.IsValid) { CLayer.User usr = new CLayer.User() { UserId = data.UserId, SalutationId = data.SalutationId, FirstName = data.FirstName, LastName = data.FirstName, Businessname = data.Name,//Businessname Email = data.Email }; long UserId = BLayer.User.Update(usr); if (UserId > 0) { CLayer.B2B b2b = new CLayer.B2B() { B2BId = data.UserId, Name = data.Name,//Businessname ContactDesignation = data.ContactDesignation }; BLayer.B2B.Update(b2b); CLayer.Address adrs = new CLayer.Address() { AddressId = data.AddressId, UserId = data.UserId, AddressText = data.Address, // CityId = data.CityId, State = data.State, CountryId = data.CountryId, Phone = data.Phone, ZipCode = data.ZipCode, Mobile = data.Mobile, AddressType = (int)CLayer.Address.AddressTypes.Normal }; if (data.CityId > 0) { adrs.City = BLayer.City.Get(data.CityId).Name; adrs.CityId = data.CityId; } else { if (data.City != null && data.City != "") { adrs.City = data.City; } } BLayer.Address.Save(adrs); //billing address Save CLayer.Address BillingAddress; if (!data.IsClicked) { BillingAddress = new CLayer.Address() { AddressId = data.BillingAddressId, AddressText = data.BillingAddress, ZipCode = data.BillingZipCode, UserId = data.UserId, CityId = data.BillingCityId, State = data.BillingState, CountryId = data.BillingCountryId, Phone = data.Phone, Mobile = data.Mobile, AddressType = (int)CLayer.Address.AddressTypes.Primary }; if (data.BillingCity != null && data.BillingCity != "") { BillingAddress.City = data.BillingCity; } if (data.BillingCityId > 0) { BillingAddress.City = BLayer.City.Get(data.BillingCityId).Name; } BLayer.Address.Save(BillingAddress); } else { BillingAddress = new CLayer.Address() { AddressId = data.BillingAddressId, AddressText = data.Address, UserId = data.UserId, ZipCode = data.ZipCode, CityId = data.CityId, City = data.City, State = data.State, CountryId = data.CountryId, Phone = data.Phone, Mobile = data.Mobile, AddressType = (int)CLayer.Address.AddressTypes.Primary }; if (data.City != null && data.City != "") { BillingAddress.City = data.City; } if (data.CityId > 0) { BillingAddress.City = BLayer.City.Get(data.CityId).Name; } BLayer.Address.Save(BillingAddress); } ViewBag.Message = "Your details updated successfully"; return(RedirectToAction("Details", new { id = data.UserId })); } else { ViewBag.Message = "The email id already used by someone else"; } } else { var errors = ModelState.Values.SelectMany(v => v.Errors); string err = ""; foreach (ModelError me in errors) { err += me.ErrorMessage.ToString(); } ViewBag.Message = err; } return(View("Details", data)); }
public ActionResult Details(long id) { Models.UserDetailModel details = null; CLayer.User data = BLayer.User.Get(id); if (data != null) { // details.FullName = data.FirstName + data.LastName; details = new Models.UserDetailModel() { UserId = data.UserId, SalutationId = data.SalutationId, FirstName = data.FirstName, LastName = data.LastName, DateOfBirth = data.DateOfBirth.ToShortDateString(), Status = data.Status, Email = data.Email, CreatedDate = data.CreatedDate, DeletedDate = data.DeletedDate, LastLoginOn = data.LastLoginOn, CustomerPaymentMode = data.CustomerPaymentMode, CustomerPaymentModeCreditDays = data.CustomerPaymentModeCreditDays }; } CLayer.B2B b2b = BLayer.B2B.Get(id); if (b2b != null) { details.MaxStaff = b2b.MaximumStaff; details.Name = b2b.Name; details.CreditPeriod = b2b.CreditPeriod; } CLayer.Address adrs = BLayer.Address.GetPrimaryOnUser(id); if (adrs != null) { details.Address = adrs.AddressText; details.AddressId = adrs.AddressId; details.State = adrs.State; details.CountryId = adrs.CountryId; details.Phone = adrs.Phone; details.Mobile = adrs.Mobile; details.ZipCode = adrs.ZipCode; if (adrs.CityId > 0) { details.City = BLayer.City.Get(adrs.CityId).Name; details.CityId = adrs.CityId; } else { if (adrs.City != null && adrs.City != "") { details.City = adrs.City; } } } CLayer.Address BillingAddress = BLayer.Address.GetBillingAddress(id); if (BillingAddress != null) { details.BillingAddressType = BillingAddress.BillingAddressType; details.BillingAddressId = BillingAddress.BillingAddressId; details.BillingAddress = BillingAddress.BillingAddress; details.BillingCityId = BillingAddress.BillingCityId; details.BillingState = BillingAddress.BillingState; details.BillingCity = BillingAddress.BillingCity; details.BillingCountryId = BillingAddress.BillingCountryId; details.BillingZipCode = BillingAddress.BillingZipCode; details.IsClicked = false; } else { details.BillingAddress = details.Address; details.BillingAddressId = 0; details.BillingAddress = details.Address; details.BillingCityId = details.CityId; details.BillingCity = details.City; details.BillingState = details.State; details.BillingCountryId = details.CountryId; details.Phone = details.Phone; details.Mobile = details.Mobile; details.BillingAddressType = (int)CLayer.Address.AddressTypes.Primary; details.BillingZipCode = details.ZipCode; details.IsClicked = true; } if (details.BillingZipCode == details.ZipCode && details.BillingAddress == details.Address && details.BillingCityId == details.CityId && details.BillingCity == details.City && details.BillingState == details.State && details.BillingCountryId == details.CountryId) { details.IsClicked = true; } details.LoadPlaces(); return(View("~/Areas/Admin/Views/Corporate/Details.cshtml", details)); }
public async Task Delete(Models.UserDetailModel entity) { _projectManagerDbContext.Users.Remove(entity); await _projectManagerDbContext.SaveChangesAsync(); }
public ActionResult Update(Models.UserDetailModel data) { if (ModelState.IsValid) { CLayer.User usr = new CLayer.User() { UserId = data.UserId, Businessname = data.Name,//Businessname SalutationId = data.SalutationId, FirstName = data.FirstName, LastName = data.FirstName, Email = data.Email }; BLayer.User.Update(usr); CLayer.B2B b2b = new CLayer.B2B() { B2BId = data.UserId, Name = data.Name,//Businessname PANNo = data.PANNo }; BLayer.B2B.Update(b2b); CLayer.Address adrs = new CLayer.Address() { AddressId = data.AddressId, UserId = data.UserId, AddressText = data.Address, //CityId = data.CityId, State = data.State, CountryId = data.CountryId, Phone = data.Phone, ZipCode = data.ZipCode, Mobile = data.Mobile, AddressType = (int)CLayer.Address.AddressTypes.Primary }; if (data.CityId > 0) { adrs.City = BLayer.City.Get(data.CityId).Name; adrs.CityId = data.CityId; } else { if (data.City != null && data.City != "") { adrs.City = data.City; } } BLayer.Address.Save(adrs); ViewBag.Message = "Your details updated successfully"; return(RedirectToAction("Details", new { id = data.UserId, B2bId = data.AffiliateId })); } else { var errors = ModelState.Values.SelectMany(v => v.Errors); string err = ""; foreach (ModelError me in errors) { err += me.ErrorMessage.ToString(); } ViewBag.Message = err; } return(View("Details", data)); }