Пример #1
0
        public IActionResult AddCustomer(CustomerRegObj customerRegObj)
        {
            try
            {
                if (customerRegObj != null)
                {
                    Customer customer = customerRegObj.Customer;
                    User     user     = customerRegObj.User;
                    Address  address  = customerRegObj.Address;
                    _customerRepository.AddCustomer(customer);
                    _userRepository.AddUser(user);
                    _addressRepository.AddAddress(address);

                    Token token       = new Token(_configuration);
                    var   tokenString = token.GenerateJSONWebToken();
                    _logger.LogInformation($"User {user.UserName} login on {DateTime.UtcNow.ToLongTimeString()}");
                    ResponseUser resSuccess = new ResponseUser(user.UserName, tokenString);
                    return(Ok(resSuccess));
                }
                else
                {
                    return(BadRequest("Request is null."));
                }
            }
            catch (Exception e)
            {
                _logger.LogError("Error in CustomerController: " + e.ToString());
                return(Problem(e.ToString()));
            }
        }
Пример #2
0
        public int AddAddress(AddressDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(AddressDTO.FormatAddressDTO(dto));

                R_Address t = AddressDTO.ConvertDTOtoEntity(dto);

                // add
                id            = Repository.AddAddress(t);
                dto.AddressId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
Пример #3
0
        public async Task <User> CompleteProfile([FromBody] UserAddress userAddress)
        {
            var user = _userRepository.Get(userAddress.User.Id).Result;

            user.FirstName = userAddress.User.FirstName;
            user.LastName  = userAddress.User.LastName;
            user.Contact   = userAddress.User.Contact;
            user.AllowEmailNotifications = userAddress.User.AllowEmailNotifications;


            Address address = new Address()
            {
                Street1 = userAddress.Address.Street1,
                Street2 = userAddress.Address.Street2,
                ZipCode = userAddress.Address.ZipCode,
                State   = userAddress.Address.State,
                Country = userAddress.Address.Country,
                UserId  = userAddress.User.Id
            };

            await _userRepository.UpdateUser(user);

            await _addressRepository.AddAddress(address);

            return(user);
        }
Пример #4
0
        public bool AddCinema(CinemaViewModel cinema)
        {
            TblAddress myAddress = new TblAddress()
            {
                CityId               = cinema.CityId,
                CountryId            = cinema.CountryId,
                StreetName           = cinema.StreetName,
                CreatedByUserId      = cinema.CreatedByUserId,
                LastModifiedByUserId = cinema.LastModifiedByUserId,
                CreatedOnDate        = DateTime.Now.ToString("dd/MM/yyyy"),
                LastModifiedOnDate   = DateTime.Now.ToString("dd/MM/yyyy"),
                IsDeleted            = false
            };

            var addressAdded = _addressRepository.AddAddress(myAddress);

            if (addressAdded)
            {
                Images image = new Images()
                {
                    ImagePath = cinema.ImagePath
                };

                _context.Images.Add(image);

                TblCinema tblCinema = new TblCinema()
                {
                    CinemaId             = cinema.CinemaId,
                    AdminUserId          = cinema.AdminUserId,
                    CinemaName           = cinema.CinemaName,
                    CinemaDescription    = cinema.CinemaDescription,
                    AdressId             = myAddress.AdressId,
                    CinemaProfilePicture = image.ImagePath,
                    CreatedByUserId      = cinema.CreatedByUserId,
                    LastModifiedByUserId = cinema.LastModifiedByUserId,
                    CreatedOnDate        = DateTime.Now.ToString("dd/MM/yyyy"),
                    LastModifiedOnDate   = DateTime.Now.ToString("dd/MM/yyyy"),
                    AdminUser            = cinema.AdminUser,
                    Adress             = cinema.Adress,
                    SeatColumns        = cinema.SeatColumns,
                    SeatsRows          = cinema.SeatsRows,
                    CreatedByUser      = cinema.CreatedByUser,
                    LastModifiedByUser = cinema.LastModifiedByUser,
                    IsDeleted          = false
                };

                var cinemaAdded = _cinemaRepository.AddCinema(tblCinema);

                if (cinemaAdded)
                {
                    return(true);
                }

                return(false);
            }

            return(false);
        }
 public IActionResult AddAddress([FromBody] Address address)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     _addressRepository.AddAddress(address);
     return(new JsonResult(address.AddressId));
 }
Пример #6
0
        public Address GetAddressCoordinates(string address)
        {
            var result = _addressRepository.GetAddressCoordinates(address);

            if (result == null)
            {
                result = GetAddressFromGoogleGeocoder(address);
                _addressRepository.AddAddress(result);
            }

            _addressRepository.UpdateNumberOfHits(address);
            return(result);
        }
Пример #7
0
 public ActionResult AddMyDetail(MyDetailModel model)
 {
     ViewBag.ok = "no";
     if (ModelState.IsValid)
     {
         try
         {
             Address ar = AddressRepository.AddAddress(0, model.AddressLine, "", model.City, model.State, model.ZipCode,
                                                       model.CrossStreet, DateTime.Now, UserName, DateTime.Now, UserName, true);
             ContactInfo ci = ContactInfoRepository.AddContactInfo(0, model.Phone, "", model.Email, DateTime.Now, UserName, DateTime.Now, UserName, true);
             UserDetail  ud = UserDetailRepository.InsertUserDetail(0, model.UserID, model.FirstName, model.LastName, ar.AddressId,
                                                                    ci.ContactInfoId, DateTime.Now, UserName, DateTime.Now, UserName, true, CryptionClass.Encrypt("no password"));
             ViewBag.ok = "yes";
             return(PartialView(model));
         }
         catch
         {
             ViewBag.ok = "no";
         }
     }
     return(PartialView(model));
 }
        public bool AddAddress(Contracts.CryptoBits.AddressOG newAddress)
        {
            var entity = GetEntity(newAddress);
            var result = _repo.AddAddress(entity);

            if (result.IsCompleted)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #9
0
        public ActionResult AddAddress([FromBody] Address address)
        {
            var res = _addressRepository.AddAddress(address);



            if (res != null)

            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Пример #10
0
 public IActionResult AddAddress(Address address)
 {
     try
     {
         if (address != null)
         {
             _addressRepository.AddAddress(address);
             return(Ok(address));
         }
         return(BadRequest("Request object is null"));
     }
     catch (Exception e)
     {
         error = "Error in CustomerController: " + e.ToString();
         _logger.LogError(error);
         return(Problem(error));
     }
 }
        public IActionResult Add([FromBody] AddressVM addressVM)
        {
            var claimsIdentity = User.Identity as ClaimsIdentity;
            var userid         = Convert.ToInt32(claimsIdentity.FindFirst(ClaimTypes.Name)?.Value);
            //8
            Address address = new Address()
            {
                //主键自增
                UserID        = userid,
                name          = addressVM.name,
                phone         = addressVM.phone,
                Province      = addressVM.Province,
                City          = addressVM.City,
                County        = addressVM.County,
                AddressDetail = addressVM.AddressDetail,
            };

            _addressRepository.AddAddress(address);
            return(Ok("添加成功"));
        }
        public IActionResult PostCandidate([FromBody] CandidateViewModel candidateVW)
        {
            int Id;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            candidateVW.candidate.AddrId    = _addressRepository.AddAddress(candidateVW.address);
            candidateVW.candidate.ContactId = _contactRepository.AddContact(candidateVW.contact);

            Id = _candidateRepository.AddCandidate(candidateVW.candidate);
            var activationCode = new Guid();

            EmailService.SendVerificationLinkEmail(candidateVW.contact.Email, activationCode.ToString(), "http", "", "");


            return(CreatedAtAction("PostCandidate", new { id = Id }, candidateVW.candidate));
        }
Пример #13
0
        public ActionResult Create(IFormCollection collection, Models.Address address)
        {
            PizzaProject1.Library.Address dmc = new Address();
            dmc.StreetOne = address.StreetOne;
            dmc.StreetTwo = address.StreetTwo;
            dmc.City      = address.City;
            dmc.State     = address.State;
            dmc.Country   = address.Country;
            dmc.Zipcode   = address.Zipcode;

            try
            {
                // TODO: Add insert logic here
                db.AddAddress(dmc);
                db.Save();
                return(RedirectToAction("Login", "Customer"));
            }
            catch
            {
                return(View());
            }
        }
        public async Task <IActionResult> Register(RegisterViewModel model)
        {
            //check if validations provided are valid
            if (ModelState.IsValid)
            {
                //create new user
                var newUser = await _userRepository.SignUp(model);

                if (!newUser.Succeeded)
                {
                    foreach (var err in newUser.Errors)
                    {
                        ModelState.AddModelError("", err.Description);
                        //log error
                        _logger.LogDebug(err.Code + ":" + err.Description);
                    }

                    return(View(model));
                }


                var userObj = await _userManager.FindByEmailAsync(model.Email);

                var userAddress = new Address()
                {
                    PostalCode       = model.PostalCode,
                    Street           = model.Street,
                    City             = model.City,
                    State            = model.State,
                    Country          = model.Country,
                    AppUserAddressId = userObj.Id
                };

                // create user address
                await _addressRepository.AddAddress(userAddress);

                //phone Number model
                var userPhone = new PhoneNumber()
                {
                    CountryCode   = model.CountryCode,
                    Number        = model.Number,
                    PhoneNumberId = userObj.Id
                };

                //add user phone number
                await _phoneNumberRepository.AddPhoneNumber(userPhone);


                var user = new AppUser()
                {
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    UserName  = model.Email,
                    Email     = model.Email,
                    //Address = userAddress,
                    PasswordHash = model.Password,
                };

                //generate a token
                var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                //generate a confirmation link

                var confirmationLink = Url.Action("ConfirmEmail", "Account", new { user.Email, token }, Request.Scheme);



                //send link to user email upon registration
                bool emailResponse = _emailService.SendEmailToConfirm(user.Email, confirmationLink);

                //checks if response is true;
                if (emailResponse)
                {
                    ViewBag.Message = "Registration Successful." +
                                      "please confirm the Email sent to your mail";

                    return(View());
                }

                ViewBag.Message = "Registration failed";

                return(View());
            }
            return(View(model));
        }
Пример #15
0
 public bool SaveAddress(Address address)
 {
     return(_addressRepository.AddAddress(address));
 }
Пример #16
0
        public async Task <IActionResult> Create(StudentCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = ProcessUploadedFile(model);

                Student student = new Student
                {
                    Fname        = model.Fname,
                    Lname        = model.Lname,
                    Email        = model.Email,
                    DepartmentId = model.DepartmentId,
                    LevelId      = model.LevelId,
                    GenderId     = model.GenderId,
                    PhotoPath    = uniqueFileName
                };

                studentRepository.Create(student);

                var studentId = context.Students.OrderBy(x => x.StudentId).Select(x => x.StudentId).LastOrDefault();

                Address address = new Address
                {
                    StudentId = studentId,
                    Address1  = model.Address1,
                    Address2  = model.Address2,
                    City      = model.City,
                    State     = model.State,
                    Country   = model.Country,
                    ZippCode  = model.ZippCode
                };

                addressRepository.AddAddress(address);


                ApplictionUser user = new ApplictionUser
                {
                    UserName     = model.Email,
                    Email        = model.Email,
                    StudentId    = student.StudentId,
                    PasswordHash = model.Password
                };

                var result = await userManger.CreateAsync(user);

                if (result.Succeeded)
                {
                    var hasedPassword = userManger.PasswordHasher.HashPassword(user, model.Password);
                    user.PasswordHash = hasedPassword;
                    await userManger.UpdateAsync(user);

                    logger.LogInformation("student added sucessfully");
                    return(View("StudentAddSuccess"));
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError(string.Empty, error.Description);
                    }
                }
            }

            return(View(model));
        }
Пример #17
0
 public void Post(AddAddressDTO newAddress)
 {
     _repo.AddAddress(newAddress);
 }
Пример #18
0
 public void AddAddress(Address address)
 {
     _addressRepository.AddAddress(address);
 }
Пример #19
0
 public void AddAddress(string email, AddressInputModel address)
 {
     _addressRepository.AddAddress(email, address);
 }
Пример #20
0
 public IActionResult AddAddress([FromBody] Address address)
 {
     return(new JsonResult(_addressRepository.AddAddress(address)));
 }
Пример #21
0
        public int AddAddress([FromBody] Address address)
        {
            int result = _addressRepository.AddAddress(address);

            return(result);
        }
Пример #22
0
 public AddressDto AddAddress(string email, AddressInputModel address)
 {
     return(_addressRepository.AddAddress(email, address));
 }
Пример #23
0
 public void WriteAddressForSpecifiedItem(AddressDto addressDto)
 {
     _commonRepo.AddAddress(_mapper.Map <AddressDto, Address>(addressDto));
 }