/// <summary> /// This function changes the Active Status of the User to "False". /// </summary> /// <param name="UserAddressDTOobject"></param> /// <returns></returns> public Boolean DeleteUser(UserAddressDTO UserAddressDTOobject) { bool flag = false; try { using (UnitOfWork uow = new UnitOfWork()) { User userObj = new User(); Address addressObj = new Address(); userObj.UserId = UserAddressDTOobject.User.UserId; userObj.FirstName = UserAddressDTOobject.User.FirstName; userObj.LastName = UserAddressDTOobject.User.LastName; userObj.MiddleName = UserAddressDTOobject.User.MiddleName; userObj.DOB = UserAddressDTOobject.User.DOB; userObj.HireDate = UserAddressDTOobject.User.HireDate; userObj.ReleaseDate = UserAddressDTOobject.User.ReleaseDate; userObj.FkRoleId = UserAddressDTOobject.User.FkRoleId; userObj.Active = false; userObj.RecordStatus = UserAddressDTOobject.User.RecordStatus; userObj.CreatedBy = UserAddressDTOobject.User.CreatedBy; userObj.CreatedDate = UserAddressDTOobject.User.CreatedDate; userObj.LastModifiedBy = DateTime.Now; userObj.LastModifiedDate = DateTime.Now.Date; uow.UserRepo.Update(userObj); uow.Complete(); flag = true; } } catch (Exception e) { Debug.WriteLine(e.Message); } return(flag); }
/// <summary> /// This function adds User's Details in the Database. /// </summary> /// <param name="UserAddressDTOobject"></param> /// <param name="LoginDTOobject"></param> /// <returns></returns> public Boolean CreateUser(UserAddressDTO UserAddressDTOobject, LoginDTO LoginDTOobject) { bool flag = false; try { using (UnitOfWork uow = new UnitOfWork()) { UserAddress useraddressObj = new UserAddress(); User userObj = new User(); Address addressObj = new Address(); Login loginObj = new Login(); userObj.FirstName = UserAddressDTOobject.User.FirstName; userObj.LastName = UserAddressDTOobject.User.LastName; userObj.MiddleName = UserAddressDTOobject.User.MiddleName; userObj.DOB = UserAddressDTOobject.User.DOB; userObj.HireDate = UserAddressDTOobject.User.HireDate; userObj.ReleaseDate = UserAddressDTOobject.User.ReleaseDate; userObj.UserProfilePicture = UserAddressDTOobject.User.UserProfilePicture; if (UserAddressDTOobject.User.FkRoleId == null || UserAddressDTOobject.User.FkRoleId <= 0) { userObj.FkRoleId = 2; } else { userObj.FkRoleId = UserAddressDTOobject.User.FkRoleId; } userObj.Active = true; userObj.RecordStatus = 1; userObj.CreatedBy = 123; userObj.CreatedDate = DateTime.Now.Date; userObj.LastModifiedBy = DateTime.Now; userObj.LastModifiedDate = DateTime.Now.Date; var User = uow.UserRepo.Add(userObj); uow.Complete(); addressObj.AddressType = 1; addressObj.Address1 = UserAddressDTOobject.Address.Address1; addressObj.Address2 = UserAddressDTOobject.Address.Address2; addressObj.City = UserAddressDTOobject.Address.City; addressObj.FkStateId = UserAddressDTOobject.Address.FkStateId; addressObj.CreatedBy = 123; addressObj.CreatedDate = DateTime.Now.Date; addressObj.LastModifiedBy = DateTime.Now; addressObj.LastModifiedDate = DateTime.Now.Date; var Address = uow.AddressRepo.Add(addressObj); uow.Complete(); useraddressObj.FkUserId = User.UserId; useraddressObj.FkAddressId = Address.AddressId; useraddressObj.CreatedBy = 123; useraddressObj.CreatedDate = DateTime.Now.Date; uow.UserAddressRepo.Add(useraddressObj); uow.Complete(); loginObj.FkUserId = User.UserId; loginObj.Username = LoginDTOobject.Username; loginObj.Password = LoginDTOobject.Password; loginObj.CreatedBy = 123; loginObj.CreatedDate = DateTime.Now.Date; loginObj.LastModifiedBy = DateTime.Now; loginObj.LastModifiedDate = DateTime.Now.Date; uow.LoginRepo.Add(loginObj); uow.Complete(); flag = true; } } catch (Exception e) { Debug.WriteLine(e.Message); } return(flag); }