public ActionResult Create(ViewSeller vseller) { if (ModelState.IsValid) { SellerAddress address = new SellerAddress(); address.Area = areaRepo.Get(vseller.Area); address.City = cityRepo.Get(vseller.City); address.ShopName = vseller.ShopName; SellerLogin login = new SellerLogin(); login.Username = vseller.Username; login.Password = vseller.Password; SellerApproval approval = new SellerApproval(); approval.Status = false; Seller seller = new Seller(); seller.FirstName = vseller.FirstName; seller.LastName = vseller.LastName; seller.Email = vseller.Email; seller.Phone = vseller.Phone; seller.Gender = vseller.Gender; seller.Address = address; seller.LoginData = login; seller.Approval = approval; sellerRepo.Insert(seller); return(RedirectToAction("Index", "Home")); } return(View(vseller)); }
public async Task <bool> UpdateCityAsync(CityDVM entity) { bool result = false; if (entity != null) { City d = cityRepository.Get(entity.CityId); if (d != null) { d.Name = entity.Name; d.StateCode = entity.StateCode; try { await cityRepository.UpdateAsync(d); result = true; } catch (Exception ex) { throw ex; } } } return(result); }
public ActionResult Create(ViewBuyer vbuyer) { if (ModelState.IsValid) { BuyerAddress address = new BuyerAddress(); address.Area = areaRepo.Get(vbuyer.Area); address.City = cityRepo.Get(vbuyer.City); address.Block = vbuyer.Block; address.House = vbuyer.House; address.Road = vbuyer.House; BuyerLogin login = new BuyerLogin(); login.Username = vbuyer.Username; login.Password = vbuyer.Password; BuyerApproval approval = new BuyerApproval(); approval.Status = false; Buyer buyer = new Buyer(); buyer.FirstName = vbuyer.FirstName; buyer.LastName = vbuyer.LastName; buyer.Email = vbuyer.Email; buyer.Phone = vbuyer.Phone; buyer.Gender = vbuyer.Gender; buyer.Address = address; buyer.LoginData = login; buyer.Approval = approval; buyerRepo.Insert(buyer); return(RedirectToAction("Index", "Home")); } return(View(vbuyer)); }
public ProfileViewModel GetProfileByUserProfileID(int userProfileID) { UserProfileRepository repo = new UserProfileRepository(); ICountryRepository countryRepo = new CountryRepository(); IStateRepository stateRepo = new StateRepository(); ICityRepository cityRepo = new CityRepository(); ProfileViewModel viewModel = new ProfileViewModel(); var yourProfile = repo.Get().Where(s => s.UserProfileID == userProfileID).FirstOrDefault(); if (yourProfile != null) { var city = cityRepo.Get().Where(s => s.CityID == yourProfile.CityID).FirstOrDefault(); var state = stateRepo.Get().Where(s => s.StateID == city.StateID).FirstOrDefault(); var country = countryRepo.Get().Where(s => s.CountryID == state.CountryID).FirstOrDefault(); viewModel.UserID = yourProfile.UserID; viewModel.UserProfileID = yourProfile.UserProfileID; viewModel.OrganizationID = yourProfile.OrganizationID; viewModel.FirstName = yourProfile.FirstName; viewModel.LastName = yourProfile.LastName; viewModel.Address = yourProfile.Address; viewModel.Gender = yourProfile.Gender; viewModel.MobileNO = yourProfile.PhoneNo; viewModel.ProfilePicPath = yourProfile.ProfilePicPath; viewModel.DOB = yourProfile.DOB; viewModel.City = city.CityName; viewModel.State = state.StateName; viewModel.Country = country.CoutnryName; } return(viewModel); }
public override IEnumerable <T> Get <T>(int start, int limit, string sort, string dir, out int totalCount, params IListParameter[] parameter) { using (Repository = new CityRepository()) { var data = Repository.Get(start, limit, sort, dir, out totalCount, parameter); return(data as IEnumerable <T>); } }
public IEnumerable <T> Get <T>(params IListParameter[] parameter) { using (Repository = new CityRepository()) { var data = Repository.Get(parameter); return(data as IEnumerable <T>); } }
public IHttpActionResult Get() { var cities = _CityRepository.Get(c => c.IsEnabled == true); return(Ok(cities.Select(c => new { Id = c.ID, Name = c.Name, }))); }
private void DropDownInit() { CategoryRepository catRep = new CategoryRepository(); List<category> categList = catRep.Get().ToList(); ViewBag.categories = new SelectList(categList, "categoryID", "name", null); CityRepository cityRep = new CityRepository(); List<city> cityList = cityRep.Get().ToList(); ViewBag.cities = new SelectList(cityList, "cityID", "name", null); }
public ActionResult CreateAdmin(ViewEmployee vEmployee) { if (ModelState.IsValid) { EmployeeLogin login = new EmployeeLogin(); login.Username = vEmployee.Username; login.Password = vEmployee.Password; login.EmployeeType = "Admin"; Area area = new Area(); area = areaRepo.Get(vEmployee.AreaName); City city = new City(); city = cityRepo.Get(vEmployee.CityName); Department dept = new Department(); dept = deptRepo.Get(vEmployee.DepartmentName); var config = new MapperConfiguration(conf => conf.CreateMap <ViewEmployee, Admin>()); var mapper = config.CreateMapper(); Admin adminToInsert = mapper.Map <Admin>(vEmployee); adminToInsert.DateOfBirth = vEmployee.DateOfBirth.ToShortDateString(); adminToInsert.JoiningDate = vEmployee.JoiningDate.ToShortDateString(); adminToInsert.LoginData = login; adminToInsert.Area = area; adminToInsert.City = city; adminToInsert.Department = dept; adminRepo.Insert(adminToInsert); return(RedirectToAction("Index")); } else { return(View(vEmployee)); } }
public async Task <CityDto> GetCityByIdAsync(int cityId) { try { var city = await _cityRepository.Get(cityId); return(_mapper.Map <CityDto>(city)); } catch (Exception) { throw; } }
public IEnumerable <City> getAllCities() { return(CityRepository.Get(filter: m => m.IsDeleted == false)); }
public async Task <ActionResult> Settings(ProfileSettingsViewModel model, HttpPostedFileBase file) { var user = await userMgr.FindByNameAsync(User.Identity.Name); List <CinemaEntity> listCinema = new List <CinemaEntity> { new CinemaEntity { Id = 0, Name = "Не вибрано" } }; listCinema.AddRange(cinemaRepository.GetAll()); List <City> listCity = new List <City> { new City { Id = 0, Name = "Не вибрано" } }; listCity.AddRange(cityRepository.GetAll()); int userFavoriteCinema = (user.FavotiteCinema == null) ? 0 : user.FavotiteCinema.Id; int userCity = (user.City == null) ? 0 : user.City.Id; ViewBag.FavoriteCinemaId = new SelectList(listCinema, "id", "name", userFavoriteCinema); ViewBag.CityId = new SelectList(listCity, "id", "name", userCity); if ((file != null && !IsImageOk(file)) || !ModelState.IsValid) { return(View(model)); } user.FirstName = model.FirstName; user.LastName = model.LastName; user.Birthday = model.Birthday; user.FavotiteCinema = cinemaRepository.Get(model.FavoriteCinemaId); user.City = cityRepository.Get(model.CityId); // зберігаю зображення if (file != null && IsImageOk(file)) { if (user.PicturePath != null && System.IO.File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, user.PicturePath))) { System.IO.File.Delete(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, user.PicturePath)); } var pictureSm = MakeThumbnail(Image.FromStream(file.InputStream), 100, 100); string picture_folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Content", "UserData", "Avatar"); string picture_name = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); string picture_folder_name = Path.Combine(picture_folder, picture_name); pictureSm.Save(picture_folder_name); //file.SaveAs(picture_folder_name); user.PicturePath = Path.Combine("Content", "UserData", "Avatar", picture_name); } var result = await userMgr.UpdateAsync(user); if (result.Succeeded) { return(RedirectToAction("Index", "Profile")); } return(View(model)); }
public City Get(int id) { return(CityRepository.Get(t => t.CityId == id)); }
public IEnumerable <City> GetCitiesByStateId(int id) { ICityRepository cityRepo = new CityRepository(); return(cityRepo.Get().Where(s => s.StateID == id).ToList()); }