public bool AddEditDeleteAddresses(AddressViewModel addressView) { dm.Address addressDomainModel = createModel.MappingAddress(addressView); // gets userinfo for edit dm.User getUser = UserHelper.GetUserInfoByIdForAddress(addressDomainModel); var valCheckAdd = validator.ValidateStreet(addressDomainModel); if (addressView.HelperType == "add") { if (valCheckAdd) { var addedAddress = new dm.Address { //AddressId = addressDomainModel.AddressId, Street = addressDomainModel.Street, City = addressDomainModel.City, State = addressDomainModel.State, PostalCode = addressDomainModel.PostalCode, User = new User { UserId = getUser.UserId, Username = getUser.Username, Password = getUser.Password, Firstname = getUser.Firstname, Lastname = getUser.Lastname, Email = getUser.Email } }; AddressHelper.AddAddressById(addedAddress); return(true); } return(false); } var editedAddress = new dm.Address { AddressId = addressDomainModel.AddressId, Street = addressDomainModel.Street, City = addressDomainModel.City, State = addressDomainModel.State, PostalCode = addressDomainModel.PostalCode, User = new User { UserId = getUser.UserId, Username = getUser.Username, Password = getUser.Password, Firstname = getUser.Firstname, Lastname = getUser.Lastname, Email = getUser.Email } }; AddressHelper.EditAddressInfoById(editedAddress); return(true); }
// receives only username and password in UserViewModel format public UserViewModel LoginValidator(UserViewModel user) { dm.User userModel = createModel.MappingUser(user); var valCheckUsername = validator.ValidateUserName(userModel); if (valCheckUsername) { var userInfo = UserHelper.GetUserInfoByUsername(userModel); return(createModel.MappingViewInfo(userInfo)); } return(null); }
public bool EmailValidator(UserViewModel email) { dm.User userModel = createModel.MappingUser(email); var valCheckEmail = validator.ValidateEmail(userModel); if (valCheckEmail) { var userInfo = UserHelper.GetUserInfoByUsername(userModel); return(true); } return(false); }
// used to sent all info in UserViewModel format for add or edit public bool AddEditUser(UserViewModel userView) { dm.User userModel = createModel.MappingUser(userView); var valCheckAdd = validator.ValidateUserName(userModel); var valCheckEdit = validator.EditExistingUser(userModel); if (userView.HelperType == "add") { if (valCheckAdd) { UserHelper.AddUser(userModel); return(true); } return(false); } if (valCheckEdit) { UserHelper.EditUserInfoById(userModel); return(true); } return(false); }
// add requires all properties, delete only needs public bool AddOrDeletePayments(PaymentViewModel paymentView) { dm.Payment paymentDomainModel = createModel.MappingPayment(paymentView); dm.User getUser = UserHelper.GetUserInfoByIdForPayment(paymentDomainModel); var valCheckAdd = validator.ValidateNewPayment(paymentDomainModel); if (paymentView.HelperType == "add") { if (valCheckAdd) { var addedPayment = new dm.Payment { PaymentId = paymentDomainModel.PaymentId, CCNumber = paymentDomainModel.CCNumber, CCUserName = paymentDomainModel.CCUserName, Month = paymentDomainModel.Month, Year = paymentDomainModel.Year, CVV = paymentDomainModel.CVV, User = new User { UserId = getUser.UserId, Username = getUser.Username, Password = getUser.Password, Firstname = getUser.Firstname, Lastname = getUser.Lastname, Email = getUser.Email } }; PaymentHelper.AddPaymentById(addedPayment); return(true); } return(false); } PaymentHelper.DeletePaymentByPaymentId(paymentDomainModel); return(true); }
public UserViewModel MappingViewInfo(dm.User user) { var userViewMapper = viewConfig.CreateMapper(); return(userViewMapper.Map <dm.User, UserViewModel>(user)); }