Esempio n. 1
0
        private void DiaChiInfoPrepare(DiaChiInfoModel model)
        {
            var states = _stateProvinceService.GetStateProvincesByCountryId(NhaXesController.CountryID);

            if (states.Count > 0)
            {
                foreach (var s in states)
                {
                    model.AvailableStates.Add(new SelectListItem {
                        Text = s.Name, Value = s.Id.ToString(), Selected = (s.Id == model.ProvinceID)
                    });
                }
                int ProvinceID = Convert.ToInt32(model.AvailableStates[0].Value);
                if (model.Id > 0 && model.ProvinceID > 0)
                {
                    ProvinceID = model.ProvinceID;
                }
                var quanhuyens = _diachiService.GetQuanHuyenByProvinceId(ProvinceID);
                model.AvailableQuanHuyens.Add(new SelectListItem {
                    Text = GetLabel("QuanHuyen.SelectQuanHuyen"), Value = "0", Selected = (model.QuanHuyenID == 0)
                });
                foreach (var s in quanhuyens)
                {
                    model.AvailableQuanHuyens.Add(new SelectListItem {
                        Text = s.Ten, Value = s.Id.ToString(), Selected = (s.Id == model.QuanHuyenID)
                    });
                }
            }
        }
Esempio n. 2
0
        public static DiaChiInfoModel ToModel(this DiaChi model)
        {
            if (model == null)
            {
                return(new DiaChiInfoModel());
            }
            DiaChiInfoModel destination = new DiaChiInfoModel();

            destination.Id          = model.Id;
            destination.DiaChi1     = model.DiaChi1;
            destination.DiaChi2     = model.DiaChi2;
            destination.DienThoai   = model.DienThoai;
            destination.Fax         = model.Fax;
            destination.MaBuuDien   = model.MaBuuDien;
            destination.ProvinceID  = model.ProvinceID;
            destination.QuanHuyenID = model.QuanHuyenID;
            destination.Latitude    = model.Latitude.ToString().Replace(",", ".");
            destination.Longitude   = model.Longitude.ToString().Replace(",", ".");
            return(destination);
        }
Esempio n. 3
0
 public static DiaChi ToEntity(this DiaChiInfoModel model, DiaChi destination)
 {
     if (model == null)
     {
         return(null);
     }
     if (destination == null)
     {
         destination = new DiaChi();
     }
     destination.Id          = model.Id;
     destination.DiaChi1     = model.DiaChi1;
     destination.DiaChi2     = model.DiaChi2;
     destination.DienThoai   = model.DienThoai;
     destination.Fax         = model.Fax;
     destination.MaBuuDien   = model.MaBuuDien;
     destination.ProvinceID  = model.ProvinceID;
     destination.QuanHuyenID = model.QuanHuyenID;
     destination.Latitude    = model.Latitude.ToDecimal();
     destination.Longitude   = model.Longitude.ToDecimal();
     return(destination);
 }