예제 #1
0
        /// <summary>
        /// CreateEntiy
        /// </summary>
        /// <param name="product">The entity.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
        public bool CreateEntiy(AddressDto t)
        {
            var dbEntity = typeAdapter.ConvertDtoToEntities(t);

            entiesrepository.Add(dbEntity);
            entiesrepository.Save();
            return(true);
        }
예제 #2
0
        public async Task <IActionResult> Create(int userId, Address address)
        {
            try
            {
                address.UserId = userId;

                _repo.Add(address);

                if (await _repo.SaveChangesAsync())
                {
                    return(Ok(address));
                }
            }
            catch (System.Exception ex)
            {
                return(this.StatusCode
                       (
                           StatusCodes.Status500InternalServerError,
                           "Erro ao inserir as informações do banco de dados\n"
                           + ex.InnerException
                       ));
            }

            return(BadRequest());
        }
예제 #3
0
 private void SaveAddress(object sender, EventArgs e)
 {
     if (btnSaveAddress.Text == "Edit")
     {
         var existingAddress = addressRepository.GetByPatientId(patientId);
         existingAddress.PatientId  = Convert.ToInt32(txtPatientIdAddress.Text);
         existingAddress.City       = txtCity.Text;
         existingAddress.Province   = txtProvince.Text;
         existingAddress.PostalCode = txtPostalCode.Text;
         if (addressRepository.Update(existingAddress) > 0)
         {
             MessageBox.Show("Updated Successfully");
         }
     }
     else
     {
         var address = new Address();
         address.PatientId  = Convert.ToInt32(txtPatientIdAddress.Text);
         address.City       = txtCity.Text;
         address.Province   = txtProvince.Text;
         address.PostalCode = txtPostalCode.Text;
         if (addressRepository.Add(address) > 0)
         {
             MessageBox.Show("Saved Successfully.");
         }
     }
     FillDataGridView();
 }
예제 #4
0
        public void AddAddressTest()
        {
            int id = testAddressId;

            using (AddressRepository res = new AddressRepository())
            {
                IAddress address = res.GetEntityById(id);

                IAddress addressNew = new biz.Address();

                //address.MapPrimitiveNullOnly(addressNew);

                addressNew.customerId = address.customerId;
                //addressNew.AddressCodeID = 1;
                addressNew.addressLine1 = "123 Test st";
                addressNew.city         = "Woodbury";
                addressNew.zipCode      = "55125";

                int addressidnew = res.Add(addressNew);

                IAddress address1 = res.GetEntityById(addressidnew);

                Assert.AreEqual(address1.addressId, addressidnew);
            }
        }
예제 #5
0
        //CREATE ADDRESS
        public Address CreateNewAddress()
        {
            IAddressRepository repoAddress = new AddressRepository(db);

            var address = new Address {
                SuburbId = 1, Street1 = "1024 Cherry Street", Street2 = "Langley Falls"
            };
            var addressTwo = new Address {
                SuburbId = 2, Street1 = "742 Evergreen Terrace", Street2 = "Evergreen Terrace"
            };

            repoAddress.Add(address);
            repoAddress.Add(addressTwo);

            return(addressTwo);
        }
예제 #6
0
        public void Address_Repository_Create_List_Delete()
        {
            //get quantity before actions
            var lst          = _objRepo.GetAll().ToList();
            var initialCount = lst.Count;

            //Arrange - City, State PostalCode required
            var obj = new Entity.Model.Address {
                Line1 = "1000 Exit Ave", City = "NewCity", State = "NY", PostalCode = "11020", Country = "USA"
            };

            //Act
            var result = _objRepo.Add(obj);

            _databaseContext.SaveChanges();

            lst = _objRepo.GetAll().ToList();

            //Assert
            Assert.AreEqual(initialCount + 1, lst.Count);
            Assert.AreEqual("NewCity", lst.Last().City);

            //Remove last added obj
            var dP = _objRepo.Delete(obj);

            _databaseContext.SaveChanges();

            lst = _objRepo.GetAll().ToList();

            //Assert
            Assert.AreEqual(initialCount, lst.Count);
        }
예제 #7
0
        // POST api/values
        public HttpResponseMessage Post([FromBody] address add)
        {
            AddressRepository repo = new AddressRepository();
            var value = repo.Add(add);

            return(Request.CreateResponse(HttpStatusCode.OK, value, Configuration.Formatters.JsonFormatter));
        }
 public void Create(Address address)
 {
     if (ZipCodeValidator.NotValid(address.Zip.ToString()))
     {
         throw new FieldValidationException("Zip", Resource.InvalidZip);
     }
     _addressRepository.Add(address);
 }
예제 #9
0
 private void SaveAddress(StoreUpModel model)
 {
     if (model.AddressId <= EntityConstants.NO_VALUE)
     {
         model.AddressId = _repositoryAddress.Add(model.AddressRes);
     }
     else
     {
         _repositoryAddress.Update(model.AddressId, model.AddressRes);
     }
 }
예제 #10
0
        /// <summary>
        /// Save Address
        /// </summary>
        /// <param name="newAddress"></param>
        /// <returns></returns>
        private Address SaveAddress(Address address)
        {
            IEntityValidator entityValidator = EntityValidatorFactory.CreateValidator();

            if (entityValidator.IsValid(address))
            {
                _addressRepository.Add(address);
                _addressRepository.UnitOfWork.Commit();

                return(address);
            }

            throw new ApplicationValidationErrorsException(entityValidator.GetInvalidMessages(address));
        }
예제 #11
0
파일: Test.cs 프로젝트: rael06/mvcConsoleCS
 public override string Start()
 {
     if (data.ContainsKey("ip") && data.ContainsKey("port"))
     {
         address         = addressRepository.New(data["ip"] as string, data["port"] as string);
         address.Success = addressRepository.Test(address);
         addressRepository.Add(address);
         context.SaveChanges();
         return("test");
     }
     else
     {
         return("errorTest");
     }
 }
예제 #12
0
        /// <summary>
        /// Save Address
        /// </summary>
        /// <param name="address"></param>
        Address SaveAddress(Address address)
        {
            var entityValidator = EntityValidatorFactory.CreateValidator();

            if (entityValidator.IsValid(address)) //if entity is valid save
            {
                //add address and commit changes
                _addressRepository.Add(address);
                _addressRepository.UnitOfWork.Commit();
                return(address);
            }
            else //if not valid, throw validation errors
            {
                throw new ApplicationValidationErrorsException(entityValidator.GetInvalidMessages(address));
            }
        }
예제 #13
0
        public async Task <bool> AddAddress(DTOAddress address)
        {
            Address mapAddress = _mapper.Map <Address>(address);

            _addressRepository.Add(mapAddress);
            bool success = true;

            try
            {
                await _addressRepository.SaveChanges();
            }
            catch (Exception e)
            {
                success = false;
            }

            return(success);
        }
예제 #14
0
        internal void InsertAddress(string street1, string street2, string city, string state, string country, string postal, string type, int contactId)
        {
            var aRep    = new AddressRepository(_uow);
            var address = new Address
            {
                Street1       = street1,
                Street2       = street2,
                City          = city,
                StateProvince = state,
                CountryRegion = country,
                ContactID     = contactId,
                PostalCode    = postal,
                AddressType   = type
            };

            aRep.Add(address);
            _uow.Save();
            RetrieveAndStoreCustomerGraph(contactId);
        }
예제 #15
0
        public void Can_Add_Address()
        {
            var address = new Address {
                HouseNumber = "67", StreetName = "Jubilee Close", City = "London", PostCode = "HA1 1BS"
            };
            IAddressRepository repo = new AddressRepository();

            repo.Add(address);

            using (var session = DatabaseConfiguration.SessionFactory().OpenSession())
            {
                var fromDb = session.Get <Address>(address.Id);

                Assert.IsNotNull(fromDb);
                Assert.AreEqual(address.HouseNumber, fromDb.HouseNumber);
                Assert.AreEqual(address.StreetName, fromDb.StreetName);
                Assert.AreEqual(address.City, fromDb.City);
                Assert.AreEqual(address.PostCode, fromDb.PostCode);
            }
        }
예제 #16
0
        public UserAddresses AddContactAddress(int userId, string streetName, string city, string country, float latitude, float longitude)
        {
            Users user = GetUserById(userId);

            if (user == null)
            {
                throw new NoEntryFoundException(userId, typeof(Users).Name);
            }

            UserAddresses address = new UserAddresses
            {
                UserId     = user.Id,
                StreetName = streetName,
                City       = city,
                Country    = country,
                Latitude   = latitude,
                Longitude  = longitude
            };

            AddressRepository.Add(address);
            return(address);
        }
예제 #17
0
        protected void LogIn_ServerClick(object sender, EventArgs e)
        {
            try
            {
                int             type        = rbtHome.Checked ? 1 : rbtOffice.Checked ? 2 : 3;
                EnumAddressType addressType = (EnumAddressType)type;
                int             userId      = UserRepository.GetUserId();
                bool            isDefault   = rbtYes.Checked ? true : false;
                using (AddressRepository addressRepository = new AddressRepository())
                {
                    if (_AddressId > 0) // Edit mode
                    {
                        AddressDetails address = addressRepository.Get(_AddressId);
                        if (address != null)
                        {
                            address.UserId        = userId;
                            address.Address       = txtAddress.Value.Trim();
                            address.Landmark      = txtLandmark.Value.Trim();
                            address.Direction     = txtDirection.Value.Trim();
                            address.CityId        = Convert.ToInt32(ddlCity.SelectedValue.Trim());
                            address.AreaId        = Convert.ToInt32(ddlArea.SelectedValue.Trim());
                            address.CountryId     = Convert.ToInt32(ddlCountry.SelectedValue.Trim());
                            address.Pincode       = txtPincode.Value.Trim();
                            address.AddressTypeId = (int)addressType;
                            if (rbtOffice.Checked || rbtOther.Checked)
                            {
                                address.OtherAddress = txtOther.Value.Trim();
                            }
                            else
                            {
                                address.OtherAddress = "NA";
                            }

                            // if IsDefault is true then make other false.
                            if (isDefault)
                            {
                                addressRepository.MakeOtherfalse(userId);
                            }

                            address.IsDefault = isDefault;
                            addressRepository.Update();

                            Response.Redirect("~/Apps/User/AddressBookList.aspx?fg=2");
                            //SuccessMessage.Visible = true;
                            //SuccessMessage.Text = "Address has been updated successfully.";
                        }
                    }
                    else // Add mode
                    {
                        if (!addressRepository.GetAddressAlreadyExistsOrNot(userId, type))
                        {
                            AddressDetails newAddress = new AddressDetails();
                            newAddress.UserId        = userId;
                            newAddress.Address       = txtAddress.Value.Trim();
                            newAddress.Landmark      = txtLandmark.Value.Trim();
                            newAddress.Direction     = txtDirection.Value.Trim();
                            newAddress.CityId        = Convert.ToInt32(ddlCity.SelectedValue.Trim());
                            newAddress.AreaId        = Convert.ToInt32(ddlArea.SelectedValue.Trim());
                            newAddress.CountryId     = Convert.ToInt32(ddlCountry.SelectedValue.Trim());
                            newAddress.Pincode       = txtPincode.Value.Trim();
                            newAddress.AddressTypeId = (int)addressType;
                            if (rbtOffice.Checked || rbtOther.Checked)
                            {
                                newAddress.OtherAddress = txtOther.Value.Trim();
                            }
                            else
                            {
                                newAddress.OtherAddress = "NA";
                            }

                            // if IsDefault is true then make other false.
                            if (isDefault)
                            {
                                addressRepository.MakeOtherfalse(userId);
                            }

                            newAddress.IsDefault = isDefault;
                            addressRepository.Add(newAddress);

                            Response.Redirect("~/Apps/User/AddressBookList.aspx?fg=1");
                            //SuccessMessage.Visible = true;
                            //SuccessMessage.Text = "New address has been added successfully.";
                        }
                        else
                        {
                            ErrorMessage.Visible = true;
                            ErrorMessage.Text    = "Address is already exists !!";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMessage.Visible = true;
                ErrorMessage.Text    = ex.Message.ToString();
            }
        }
예제 #18
0
        protected void txtSubmit_ServerClick(object sender, EventArgs e)
        {
            try
            {
                using (UserRepository repository = new UserRepository())
                {
                    if (!repository.CheckUserisExistOrNot(txtUserName.Value.Trim()))
                    {
                        if (!repository.IsEmailIsExists(txtUserName.Value.Trim()))
                        {
                            string activationCode = Guid.NewGuid().ToString();
                            Users  newUsers       = new Users
                            {
                                AlternateNumber  = txtalNumber.Value.Trim(),
                                EmailId          = txtAddress.Value.Trim(),
                                FirstName        = txtfirstname.Value.Trim(),
                                IsFollowUp       = chkFollowUp.Checked,
                                LastName         = txtlastname.Value.Trim(),
                                MobileNumber     = txtMobileNumber.Value.Trim(),
                                Password         = txtpassword.Value.Trim(),
                                RegistrationDate = System.DateTime.Now,
                                RoleId           = (int)EnumAccountType.User,
                                Status           = false,
                                UserName         = txtUserName.Value.Trim(),
                                ActivationCode   = activationCode
                            };
                            newUsers = repository.Add(newUsers);
                            if (chkAddress.Checked)
                            {
                                int             type        = rbtHome.Checked ? 1 : rbtOffice.Checked ? 2 : 3;
                                EnumAddressType addressType = (EnumAddressType)type;

                                AddressDetails newAddress = new AddressDetails();
                                newAddress.UserId        = newUsers.UserId;
                                newAddress.Address       = txtAddress.Value.Trim();
                                newAddress.Landmark      = txtLandmark.Value.Trim();
                                newAddress.Direction     = txtDirection.Value.Trim();
                                newAddress.CityId        = Convert.ToInt32(ddlCity.SelectedValue.Trim());
                                newAddress.AreaId        = Convert.ToInt32(ddlArea.SelectedValue.Trim());
                                newAddress.CountryId     = Convert.ToInt32(ddlCountry.SelectedValue.Trim());
                                newAddress.Pincode       = txtPincode.Value.Trim();
                                newAddress.AddressTypeId = (int)addressType;
                                if (rbtOffice.Checked || rbtOther.Checked)
                                {
                                    newAddress.OtherAddress = txtOther.Value.Trim();
                                }
                                else
                                {
                                    newAddress.OtherAddress = "NA";
                                }
                                newAddress.IsDefault = true;
                                using (AddressRepository addressRepository = new AddressRepository())
                                    addressRepository.Add(newAddress);
                            }

                            // Send varification email for registration.
                            string url = string.Empty;
                            url = Request.Url.AbsoluteUri.Replace("Register", "VerifyEmailAddress.aspx?ActivationCode=" + activationCode.ToString());
                            if (Request.Url.AbsoluteUri.Contains(".aspx"))
                            {
                                Request.Url.AbsoluteUri.Replace("Register.aspx", "VerifyEmailAddress.aspx?ActivationCode=" + activationCode.ToString());
                            }
                            string sBody = string.Empty;
                            sBody  = "Hello " + newUsers.UserName.Trim() + ",";
                            sBody += "<br /><br />Please click the following link to activate your account";
                            sBody += "<br /><a href = '" + url + "'>Click here to activate your account.</a>";
                            sBody += "<br /><br />Thanks";
                            EmailHelper.SendMail("", newUsers.EmailId, "Account Activation", sBody);
                            this.ShowSuccessfulNotification("Your registration successful. Activation email has been sent to your register email address.");
                        }
                        else
                        {
                            this.ShowErrorNotification("Email address is already exists, Please register with another email address.");
                        }
                    }
                    else
                    {
                        this.ShowErrorNotification("Username is already exists, Please select another username.");
                    }
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorNotification("Error in txtSubmit_ServerClick : " + ex.Message.ToString());
            }
        }
 public bool Add(Address address)
 {
     return(_addressRepository.Add(address));
 }
예제 #20
0
 public void Post([FromBody] Address address)
 {
     _repo.Add(address);
 }
예제 #21
0
        public Response <Model.Shopper> Create(Model.Shopper entity)
        {
            IShopperRepository        shopperRepository = null;
            IAddressRepository        addressRepository = null;
            Validator <Model.Shopper> validator         = ValidationFactory.CreateValidator <Model.Shopper>("Create");
            Validator <Model.Address> validatorAddress  = ValidationFactory.CreateValidator <Model.Address>("Create");

            try
            {
                #region Validation

                if (!validator.Validate(entity).IsValid)
                {
                    response.Status     = ResponseStatus.ErrorValidation;
                    response.ErrorValue = (int)ErrorCode.InvalidData;

                    foreach (var result in validator.Validate(entity))
                    {
                        if (!response.Validations.ContainsKey(result.Key))
                        {
                            response.Validations.Add(result.Key, result.Message);
                        }
                    }

                    return(response);
                }

                if (!validatorAddress.Validate(entity).IsValid)
                {
                    response.Status     = ResponseStatus.ErrorValidation;
                    response.ErrorValue = (int)ErrorCode.InvalidData;

                    foreach (var result in validatorAddress.Validate(entity))
                    {
                        if (!response.Validations.ContainsKey(result.Key))
                        {
                            response.Validations.Add(result.Key, result.Message);
                        }
                    }

                    return(response);
                }

                #endregion Validation

                using (var ctx = new ChickenScratchContext())
                {
                    // Set default
                    entity.FromDate     = DateTime.UtcNow;
                    entity.LastActivity = DateTime.MinValue;

                    // Create Customer
                    shopperRepository = new ShopperRepository(ctx);
                    shopperRepository.Insert(entity);

                    // Create Adrress
                    addressRepository = new AddressRepository(ctx);
                    addressRepository.Add(entity.Address);

                    shopperRepository.Save();

                    response.Result = entity;
                    response.Status = ResponseStatus.Success;
                }

                return(response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }