public IEnumerable <dynamic> GetPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount) { var query = BusinessRepository.GetQuery(); var queryTrader = TraderRepository.GetQuery(); var queryBrand = BrandRepository.GetQuery(); var title = nvl["title"]; if (!title.IsNullOrEmpty()) { query = query.Where(o => o.Title.Contains(title) || o.Byname.Contains(title)); } var q = from x in query select new { x.Id, x.Title, x.Byname, x.ById, x.CreateDT, x.CreateUID, x.Status, StateTitle = x.Status == 1 ? "可用" : "禁用", TraderNum = queryTrader.Count(o => ("," + o.BusinessScopeId + ",").Contains("," + x.ById + ",")) }; recordCount = q.Count(); return(q.ToPageList()); }
public ActionResult GetSearchUserType(int id, bool isApplicant) { ApplicantRepository ar = null; BusinessRepository br = null; applicant applicant = null; business business = null; if (isApplicant) { ar = new ApplicantRepository(); br = new BusinessRepository(); applicant = ar.SelectOne(id); } else { br = new BusinessRepository(); business = br.SelectOne(id); } if (applicant != null && User.IsInRole("Business") && (br.CheckApproved(User.Identity.GetUserName()) || User.IsInRole("Admin"))) { return(ApplicantViewProfile(ar.ToViewModel(applicant), null)); } else if (business != null && User.IsInRole("Applicant")) { return(BusinessSearchViewProfile(br.ToViewModel(business))); } else { return(View("Error")); } }
public BContact() : base() { phoneAddresses = new BusinessRepository<BPhoneAddress>(); emails = new BusinessRepository<BEmail>(); addresses = new BusinessRepository<BAddress>(); }
public Pharos.Utility.OpResult SaveOrUpdate(Business model) { if (BusinessRepository.GetQuery(o => o.Title == model.Title && o.Id != model.Id).Any()) { return(Utility.OpResult.Fail("该名称已存在!")); } if (model.Id == 0) { model.ById = CommonService.GUID; model.CreateDT = DateTime.Now; model.CreateUID = CurrentUser.UID; model.Status = 1; BusinessRepository.Add(model); } else { var source = BusinessRepository.Get(model.Id); model.ToCopyProperty(source, new List <string>() { "CreateDT", "CreateUID", "Status" }); BusinessRepository.SaveChanges(); } return(Utility.OpResult.Success()); }
public OpResult Deletes(int[] ids) { var list = BusinessRepository.GetQuery(o => ids.Contains(o.Id)).ToList(); BusinessRepository.RemoveRange(list); return(Utility.OpResult.Success()); }
public BusinessService(UserAddressRepository userAddressRepo, OrderRepository orderRepo, BusinessRepository businessRepo, ApplicationUserManager userMan) { _userAddressRepo = userAddressRepo; _orderRepo = orderRepo; _businessRepo = businessRepo; _userManager = userMan; }
static void Main(string[] args) { Console.WriteLine("Enter number Of businesses to run"); var businessCount = int.Parse(Console.ReadLine()); var businessRepository = new BusinessRepository(); var rng = new Random(); for (int i = 0; i < businessCount; i++) { var businessType = rng.Next(1, 4); string result = ""; switch (businessType) { case 1: result = businessRepository.SmallBusiness(); break; case 2: result = businessRepository.MediumBusiness(); break; case 3: result = businessRepository.Longbusiness(); break; } Console.WriteLine(result); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, [Table("Businesses", Connection = Defaults.DefaultStorageConnection)] CloudTable table, ILogger log) { // Bind query from router query QueryBusinessParameters query; try { query = GetModelFromQueryParameters(req.Query); } catch (ValidationException ex) { return(new BadRequestErrorMessageResult(ex.Message)); } // Create actual query var repository = new BusinessRepository(table); try { var results = repository.QueryAsync(query); return(new OkObjectResult(results)); } catch (Exception ex) { log.LogError(ex, "Couldn't retrieve items using query {Query}", query); return(new InternalServerErrorResult()); } }
public List <string> Search(string searchTerm) { BusinessRepository repo = new BusinessRepository(); // We instantiate our repository in charge of fetching the data var businessNames = repo.GetBusinessNames(searchTerm); // We fetch the data return(businessNames); }
public ActionResult Add(string companyName, string lastName, string firstName, string phone, string address, string city, string province, string country, string postalCode, string latitude, string longitude) { BusinessRepository ab = new BusinessRepository(); ab.AddCompany(companyName, lastName, firstName, phone, address, city, province, country, postalCode, latitude, longitude); return(RedirectToAction("Index", "Home")); }
public OpResult SetState(string ids, short state) { var sId = ids.Split(',').Select(o => int.Parse(o)); var olist = BusinessRepository.GetQuery(o => sId.Contains(o.Id)).ToList(); olist.Each(o => o.Status = state); return(OpResult.Result(BusinessRepository.SaveChanges())); }
public ActionResult Remove(int id) { BusinessRepository rb = new BusinessRepository(); rb.RemoveCompany(id); ViewData["Message"] = "Organization successfully removed."; return(RedirectToAction("Index", "Home")); }
public ActionResult <ICollection <BusinessDto> > GetSolidarityBusinesses(Guid?city) { if (city == null) { return(Ok(Mapper.Map <ICollection <BusinessDto> >(BusinessRepository.GetAllBusinessWithSolidarityDinners()))); } return(Ok(Mapper.Map <ICollection <BusinessDto> >(BusinessRepository.GetBusinessWithSolidarityDinners((Guid)city)))); }
public IActionResult DeleteBusiness(Guid ID) { return(BusinessRepository.GetBusinessByID(ID).Match <IActionResult>(None: () => NotFound(), Some: (data) => { BusinessRepository.DeleteBusiness(ID); BusinessRepository.SaveChanges(); return NoContent(); })); }
public ActionResult <BusinessDto> GetAccountData() { var businessID = new JwtSecurityToken(Request.Cookies["token"]).Claims.First(c => c.Type == "aud").Value;; return(BusinessRepository.GetBusinessByID(Guid.Parse(businessID)) .Match <ActionResult <BusinessDto> > (None: () => NoContent(), Some: (data) => Ok(Mapper.Map <BusinessDto>(data)))); }
public List <Business> GetParentList(bool all = true) { var query = BusinessRepository.GetQuery(o => (o.ParentId == null || o.ParentId == "")); if (!all) { query = query.Where(o => o.Status == 1); } return(query.ToList()); }
public List <Business> GetList(bool all = true) { var query = BusinessRepository.GetQuery(); if (!all) { query = query.Where(o => o.Status == 1); } return(query.ToList()); }
/// <summary> /// 获取一级类目 /// </summary> /// <returns></returns> public List <Business> getBusiness1(string defaultTitle = "请选择") { var business1 = BusinessRepository.GetQuery(o => o.Status == 1 && (o.ParentId == null || o.ParentId == "")).ToList(); business1.Insert(0, new Business() { ById = "", Title = defaultTitle }); return(business1); }
public BusinessViewModel GetBusinessByName(string businessName) { BusinessRepository repo = new BusinessRepository(); var business = repo.GetBusinessByName(businessName); var businessViewModel = Mapper.Map <BusinessViewModel>(business); return(businessViewModel); }
public ActionResult <List <BusinessDto> > GetAllBusinesses() { var businesses = BusinessRepository.GetAllBusinesses(); if (businesses.Count > 0) { return(Ok(Mapper.Map <List <BusinessDto> >(businesses))); } return(NoContent()); }
public List <BusinessViewModel> Search(SearchBusinessModel searchModel) { BusinessRepository repo = new BusinessRepository(); var businesses = repo.GetBusinesses(searchModel.EntityId, searchModel.EntityName, searchModel.PrincipalAddress2, searchModel.PrincipalAddress1, searchModel.PrincipalCity, searchModel.PrincipalZipCode); var businessViewModels = Mapper.Map <List <BusinessViewModel> >(businesses); return(businessViewModels); }
public ActionResult BusinessDetails(int id) { BusinessRepository businessRepository = new BusinessRepository(); BusinessViewModel business = businessRepository.SelectOneAsViewModel(id); ViewBag.Fields = business.Fields; ViewBag.Positions = business.Positions; return(View(business)); }
public bool AuthenticateBusiness(Credentials credentials) { var principal = BusinessRepository.GetBusinessCredentialsByUsername(credentials.Username); if (principal == null) { return(false); } return(SlowEquals(principal.Password, HashPassword(credentials.Password, principal.Salt))); }
public void BusinessRepository_AddingUniquePolymorph_DoesNotIncreaseSize() { //Arrange: Create an empty repository BusinessRepository<MockBusinessUnit> collection = new BusinessRepository<MockBusinessUnit>(); //Act: an entry is added collection.Create(new MockPolymorphicBusinessUnit()); //Assert: The size is still zero. Assert.AreEqual(collection.Count, 0); }
public ActionResult EditBusiness([Bind(Include = "BusinessID,Email,BusinessName,FirstName,LastName,Fields,Positions,Street,City,State,Zip,Phone,Alumni,NonProfit,Outlet,Display,DisplayDescription,Attendees,BusinessDescription,Website,SocialMedia,Photo,LocationPreference,ContactMe,PreferEmail")] BusinessViewModel business, HttpPostedFileBase fileUpload, FormCollection collection) { if (User.Identity.GetUserName() == business.Email) { try { ViewBag.Positions = business.Positions; TechCareerFair.DAL.FieldDAL.FieldRepository fr = new TechCareerFair.DAL.FieldDAL.FieldRepository(); List <field> fields = fr.SelectAll().ToList(); foreach (field f in fields) { bool isChecked = Convert.ToBoolean(collection[f.Name].Split(',')[0]); if (!business.Fields.Contains(f.Name) && isChecked) { business.Fields.Add(f.Name); } else if (business.Fields.Contains(f.Name) && !isChecked) { business.Fields.Remove(f.Name); } } if (collection["removeImage"] != null && Convert.ToBoolean(collection["removeImage"].Split(',')[0])) { business.Photo = ""; if ((System.IO.File.Exists(Server.MapPath("~") + business.Photo))) { System.IO.File.Delete(Server.MapPath("~") + business.Photo); } } if (fileUpload != null) { business.Photo = DAL.DatabaseHelper.UploadFile(DataSettings.BUSINESS_DIRECTORY, fileUpload, Server); } BusinessRepository businessRepository = new BusinessRepository(); businessRepository.UpdateBusinessProfile(business, Server.MapPath("~")); return(GetUserType(null)); } catch (ArgumentException e) { ViewBag.Error = e.Message; return(View(business)); } } else { return(RedirectToAction("AccessDenied", "Error")); } }
public CompanyAuthorize GetOneTitleByCID(int cid) { var company = CompanyAuthorRepository.GetQuery(o => o.CID == cid).OrderByDescending(o => o.CreateDT).FirstOrDefault(); if (company != null && !company.OpenScopeId.IsNullOrEmpty()) { var scopeids = company.OpenScopeId.Split(','); company.OpenScopeId = string.Join(",", BusinessRepository.GetQuery(o => scopeids.Contains(o.ById)).Select(o => o.Title)); } return(company); }
public ActionResult CreateBusinessCSV() { string fileName = "accounts.csv"; string csvFile = Server.MapPath("~" + "/Content/") + fileName; BusinessRepository br = new BusinessRepository(); br.CreateBusinessCSV(csvFile); string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; return(File(csvFile, contentType, fileName)); }
public ActionResult DeletePosition(int id) { TechCareerFair.DAL.PositionDAL.PositionRepository pr = new DAL.PositionDAL.PositionRepository(); position position = pr.SelectOne(id); BusinessRepository br = new BusinessRepository(); business bus = br.SelectOne(position.Business); ViewBag.Business = bus.BusinessName; return(View(position)); }
public UnitOfWork(ApplicationDbContext context) { _context = context; Businesses = new BusinessRepository(context); LifeInfos = new LifeInfoRepository(context); Categories = new CategoryRepository(context); Locations = new LocationRepository(context); Areas = new AreaRepository(context); RestaurantOwnerships = new RestaurantOwnershipRepository(context); EventPlaces = new EventPlaceRepository(context); FollowRestaurants = new FollowRestaurantRepository(context); }
public async Task <ActionResult> CreateBusiness(BusinessViewModel business, HttpPostedFileBase fileUpload, FormCollection collection) { if (ModelState.IsValid) { try { TechCareerFair.DAL.FieldDAL.FieldRepository fr = new TechCareerFair.DAL.FieldDAL.FieldRepository(); IEnumerable <field> iFields = fr.SelectAll(); List <field> fields = iFields.ToList(); ViewBag.AllFields = iFields; ViewBag.States = DataSettings.US_STATES; foreach (field f in fields) { bool isChecked = Convert.ToBoolean(collection[f.Name].Split(',')[0]); if (isChecked) { business.Fields.Add(f.Name); } } business.State = collection["state"]; if (fileUpload != null) { business.Photo = DAL.DatabaseHelper.UploadFile(DataSettings.BUSINESS_DIRECTORY, fileUpload, Server); } BusinessRepository br = new BusinessRepository(); br.Insert(br.ToModel(business)); EditUserViewModel user = new EditUserViewModel(); user.Email = business.Email; user.Password = business.Password; user.ConfirmPassword = business.ConfirmPassword; await CreateUserAsync(user, false); return(RedirectToAction("ListBusinesses")); } catch (ArgumentException e) { ViewBag.Error = e.Message; return(View(business)); } } else { return(View(business)); } }
public ActionResult ListPositions(int id) { TechCareerFair.DAL.PositionDAL.PositionRepository pr = new DAL.PositionDAL.PositionRepository(); BusinessRepository businessRepository = new BusinessRepository(); business business = businessRepository.SelectOne(id); ViewBag.Business = business.BusinessName; ViewBag.ID = id; List <position> positions = business.Positions; return(View(positions)); }
public ActionResult DeleteBusiness(int id, FormCollection collection) { try { BusinessRepository businessRepository = new BusinessRepository(); businessRepository.Delete(id, Server.MapPath("~")); return(RedirectToAction("ListBusinesses")); } catch { return(View()); } }
public void BusinessRepository_EditingEntries_ChangesAttributes() { //Arrange: Create a repository with one entry with a unique string attribute. BusinessRepository<MockBusinessUnit> collection = new BusinessRepository<MockBusinessUnit>(); MockBusinessUnit unit = new MockBusinessUnit { attrOne = 1, attrTwo = "Identifier" }; collection.Create(unit); int attrOne = unit.attrOne; //Act: Change the entry and update the repository to reflect unit = new MockBusinessUnit { attrOne = 2, attrTwo = "Identifier" }; collection.Update(unit); //Assert: The first entry will have an attribute of two. Assert.AreEqual(attrOne, 1); Assert.AreEqual(collection.ToArray()[0].attrOne, 2); }
public void BusinessRepository_EditingEntries_OnlyChangesTargeted() { //Arrange: Create a repository with two entries BusinessRepository<MockBusinessUnit> collection = new BusinessRepository<MockBusinessUnit>(); int prevFirstAttrOne = 1; int prevSecondAttrOne = 1; collection.Create(new MockBusinessUnit { attrOne=prevFirstAttrOne, attrTwo="Targeted"}); collection.Create(new MockBusinessUnit { attrOne=prevSecondAttrOne, attrTwo="Not targeted"}); //Act: An edit is made to the targetted entry collection.Update(new MockBusinessUnit { attrOne=2, attrTwo="Targeted"}); //Assert: The targetted entry has changed to 2, the other is still at 1 Assert.AreEqual(collection.ToArray()[0].attrOne, 2); Assert.AreEqual(collection.ToArray()[1].attrOne, 1); }
public void BusinessRepository_EditingPolymorphic_DoesNotChangeCollection() { //Arrange: Create a repository a single entry BusinessRepository<MockBusinessUnit> collection = new BusinessRepository<MockBusinessUnit>(); int prevFirstAttrOne = 1; collection.Create(new MockBusinessUnit { attrOne = prevFirstAttrOne, attrTwo = "Targeted" }); //Act: An edit attempt is made by passing an equivilant polymorph collection.Update(new MockPolymorphicBusinessUnit { attrOne = 2, attrTwo = "Targeted" }); //Assert: The element in the collection has not been changed. Assert.AreEqual(collection.ToArray()[0].attrOne, prevFirstAttrOne); }
public OrderService(OrderRepository repo, BusinessRepository businessRepo, CustomerRepository customerRepo) { _repo = repo; _businessRepo = businessRepo; _customerRepo = customerRepo; }
public void BusinessRepository_RemovingNonExistantEntry_DoesNotDecreaseSize() { //Arrange: Create a repository with one entry with a unique string attribute. BusinessRepository<MockBusinessUnit> collection = new BusinessRepository<MockBusinessUnit>(); MockBusinessUnit unit = new MockBusinessUnit { attrTwo = "Identifier" }; collection.Create(unit); int Size_Before = collection.Count; //Act: remove the added entry from the repository collection.Delete(new MockBusinessUnit { attrTwo = "Is not stored"}); //Assert: the size has not changed Assert.AreEqual(collection.Count, Size_Before); }
public void BusinessRepository_RemovingExistingPolymorph_DoesNotDecreaseSize() { //Arrange: Create a repository with one entry with a unique string attribute. BusinessRepository<MockBusinessUnit> collection = new BusinessRepository<MockBusinessUnit>(); MockBusinessUnit unit = new MockBusinessUnit { attrTwo = "Identifier" }; collection.Create(unit); int Size_Before = collection.Count; //Act: remove a polymorphic entry which would be considered business equivilant collection.Delete(new MockPolymorphicBusinessUnit { attrTwo = "Identifier" }); //Assert: the size has not changed Assert.AreEqual(collection.Count, Size_Before); }
public void BusinessRepository_RemovingEntry_DecreasesSize() { //Arrange: Create a repository with one entry with a unique string attribute. BusinessRepository<MockBusinessUnit> collection = new BusinessRepository<MockBusinessUnit>(); MockBusinessUnit unit = new MockBusinessUnit { attrTwo = "Identifier" }; collection.Create(unit); Assert.AreEqual(collection.Count, 1); //Act: remove the added entry from the repository collection.Delete(unit); //Assert: the size is now at zero Assert.AreEqual(collection.Count, 0); }