public ActionResult Create(AddressCreateModel addressCreateModel)
        {
            try
            {
                if(ModelState.IsValid)
                {

                    using (var unitIfWork = new UnitOfWork())
                    {
                        unitIfWork.InsertProfileAddress(User.Identity.Name,
                                                        addressCreateModel.Address1,
                                                        addressCreateModel.Address2,
                                                        addressCreateModel.Address3,
                                                        int.Parse(addressCreateModel.City),
                                                        addressCreateModel.PostalCode);
                    }
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        // GET: Address/Create
        public ActionResult Create()
        {
            var addressCreateModel = new AddressCreateModel();
            using (var unitOfWork = new UnitOfWork())
            {
                var result = unitOfWork.CountryRepository.Get();
                addressCreateModel.Countries = new List<SelectListItem>();

                foreach (var res in result)
                {
                    addressCreateModel.Countries.Add(new SelectListItem { Text = res.Name, Value = res.Code });
                }

            }
            return View(addressCreateModel);
        }
        public ActionResult Create(PromotionCreateModel promotion)
        {
            String[] stringList = new String[50];
            try
            {
                if (ModelState.IsValid)
                {
                    if (!String.IsNullOrEmpty(promotion.Tags))
                    {
                         stringList = promotion.Tags.Split(',');

                    }

                    using (var unitOfWork = new UnitOfWork())
                    {
                        var promId = unitOfWork.InsertPromotionDetailsByUsername(promotion.Price,promotion.Description,promotion.StartDate,promotion.EndDate,User.Identity.Name);
                        if (promId.HasValue)
                        {
                            foreach (var s in stringList.ToList())
                            {
                                if (!String.IsNullOrEmpty(s))
                                {
                                    var tag = s.Trim();
                                    unitOfWork.InsertPromotionTag(promId, tag);
                                }

                            }
                        }

                    }

                }

                    return RedirectToAction("Index");
            }
            catch(Exception ex)
            {
                return View();
            }
        }
 public ProfileController()
 {
     unitOfWork = new UnitOfWork();
 }
 public LocationServiceController()
 {
     unitOfWork = new UnitOfWork();
 }
        public ActionResult Index()
        {
            if (!String.IsNullOrEmpty(User.Identity.Name))
            {
                using (var unitOfWork = new UnitOfWork())
                {
                    var resultList = unitOfWork.GetProfileAddressByUsername(User.Identity.Name);

                    if (resultList != null)
                    {
                        var addressList = new List<AddressViewModel>();

                        foreach (var r in resultList)
                        {
                            var serviceLoc = new AddressViewModel()
                            {
                                Address1 = r.Address1,
                                Address2 = r.Address2,
                                Address3 = r.Address3,
                                AddressId = r.AddressId,
                                City = r.City,
                                State = r.State,
                                Country = r.Country,
                                PostalCode = r.PostalCode
                            };
                            addressList.Add(serviceLoc);
                        }

                        return View(addressList);
                    }
            }

            return View(new List<PointOfServiceViewModel>());
            }

            return RedirectToAction("Login", "Account");
        }
 public JsonResult GetStates(string code)
 {
     List<SelectListItem> states = new List<SelectListItem>();
     using (var unitOfWork = new UnitOfWork())
     {
         var result = unitOfWork.GetStateByCountryCode(code);
         foreach (var res in result)
         {
             states.Add(new SelectListItem { Text = res.State, Value = res.State });
         }
     }
     return Json(new SelectList(states, "Value", "Text"));
 }
 public JsonResult GetCities(string state)
 {
     List<SelectListItem> cities = new List<SelectListItem>();
     using (var unitOfWork = new UnitOfWork())
     {
         var result = unitOfWork.GetCityByState(state);
         foreach (var res in result)
         {
             cities.Add(new SelectListItem { Text = res.City, Value = res.CityId.ToString() });
         }
     }
     return Json(new SelectList(cities, "Value", "Text"));
 }
        // GET: Promotion
        public ActionResult Index()
        {
            var promotion = new PromotionViewModel();
            using (var unitOfWork = new UnitOfWork())
            {

               var result = unitOfWork.GetPromotionDetailByUsername(User.Identity.Name);

                if (result != null)
                {
                    promotion = new PromotionViewModel()
                    {
                        PromotionId = result.PromotionId,
                        Description = result.Description,
                        EndDate = result.EndDate,
                        Expertise = result.Expertise,
                        Price = result.Price,
                        StartDate = result.StartDate

                    };
                    var resultTags = unitOfWork.GetPromotionTagsByPromotionId(promotion.PromotionId).Select(x => new TagViewModel()
                    {
                        Tag = x.Tag,
                        TagId = x.TagId

                    }
                    );

                    promotion.Tags = resultTags.ToList();
                }
                else
                {
                    return RedirectToAction("Create");
                }
            }
                return View(promotion);
        }
 public HomeController()
 {
     unitOfWork = new UnitOfWork();
 }
        public ActionResult Index()
        {
            var user = new ProfileDetailsViewModel();
            if (String.IsNullOrEmpty(User.Identity.Name))
            {
                RedirectToAction("Login", "Account");
            }

            using (var unitOfWork = new UnitOfWork())
            {
                var result = unitOfWork.GetProfileDetailsByUsername(User.Identity.Name);

                if (result != null)
                {
                    user = new ProfileDetailsViewModel()
                    {
                        Username = result.Username,
                        Name = result.Name,
                        ContactNumber = result.ContactNumber,
                        Profession = result.Profession,
                        ProfileId = result.ProfileId
                    };
                    return View(user);

                }
                else
                {
                    return RedirectToAction("CreateProfile");
                }

            }
        }