public ActionResult MajorOfBusiness(BusinessViewModel businessViewModel) { string message = ""; if (ModelState.IsValid) { MajorOfBusiness Business = Mapper.Map <MajorOfBusiness>(businessViewModel); if (_majorOfBusinessManager.Add(Business)) { message = "Successfully Registration "; } else { message = " Not Registration"; } } else { message = "Registration Failed"; } ViewBag.Message = message; businessViewModel.MajorOfBusinesses = _majorOfBusinessManager.GetAll(); // return RedirectToAction("Index", "Student"); return(View()); }
public IActionResult LandingPageReload(BusinessViewModel businessModel) { SearchViewModel model = new SearchViewModel(); List <Business> businessList = new List <Business>(); businessList = _businessService.GetAllReleventBusiness(businessModel.SearchViewModel.selectedCity, businessModel.SearchViewModel.selectedCategories[0]); BusinessViewModel businessViewModel = new BusinessViewModel(); businessViewModel.Businesses = businessList; List <string> Cities = new List <string>(); Cities = _businessService.GetALLCities(); List <City> cities = new List <City>(); int i = 0; foreach (var city in Cities) { City newCity = new City { CityID = city, CityName = city }; cities.Add(newCity); i++; } model.Cities = cities; List <Category> categories = new List <Category>(); categories = _businessService.GetAllCategories(); model.Categories = categories; businessViewModel.SearchViewModel = model; return(View("Index", businessViewModel)); }
// GET: Business public ActionResult Index() { BusinessViewModel model = new BusinessViewModel(); List <Vara> VaraList = new List <Vara>(); // We changed name on project and the service reference requires the old name namespace. Labb2.LagerServiceReference.Service1Client client = new Labb2.LagerServiceReference.Service1Client(); var temp = client.GetListVara(); // It was supposed to look like: "model.VaraList = client.GetListVara();", but it did not work. // The original plan was to use the line above "var temp", but the model is unable to directly converted. Our solution was a loop. foreach (var item in temp) { Vara TempVara = new Vara(); // Create new object each loop TempVara.ID = item.ID; TempVara.Namn = item.Namn; TempVara.ButikAntal = item.ButikAntal; TempVara.LagerAntal = item.LagerAntal; TempVara.Pris = item.Pris; VaraList.Add(TempVara); // insert TempVara to create new list item } model.VaraList = VaraList; // Insert list from the loop into the model list return(View(model)); }
public async Task <ActionResult> RegisterBusiness(BusinessViewModel model, HttpPostedFileBase fileUpload, FormCollection collection) { FieldDatabaseDataService Fds = new FieldDatabaseDataService(); List <field> fields = Fds.Read(); ViewBag.Fields = fields; ViewBag.ErrCheckFields = model.Fields; ViewBag.States = DAL.DataSettings.US_STATES; if (IsValidCaptcha()) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { try { UserManager.AddToRole(user.Id, "Business"); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); if (fileUpload != null) { model.Photo = DAL.DatabaseHelper.UploadFile(DAL.DataSettings.BUSINESS_DIRECTORY, fileUpload, Server); } DAL.BusinessRepository br = new DAL.BusinessRepository(); List <business> businesses = br.SelectAll().ToList(); model.Approved = false; model.Active = true; br.Insert(br.ToModel(model)); LoginViewModel loginModel = new LoginViewModel(); loginModel.Email = model.Email; return(RedirectToAction("Index", "Home")); } catch (ArgumentException e) { ViewBag.Error = e.Message; return(View()); } } AddErrors(result); } } // If we got this far, something failed, redisplay form return(View()); }
public ActionResult View(Guid id) { using (UnitOfWorkManager.NewUnitOfWork()) { var business = _businessService.Get(id); if (business != null) { var viewModel = new BusinessViewModel { Id = business.Id, Name = business.Name, Description = business.Description, PhysicalAddress = business.PhysicalAddress, PhysicalCity = business.PhysicalCity, PhyscialState = business.PhysicalState, PhysicalZipcode = business.PhysicalZipcode, Avatar = business.Avatar, Phone = business.Phone, WebAddress = business.WebAddress, businessContacts = business.BusinessContacts.ToList() }; if (business.Classification != null) { viewModel.Classification = business.Classification.Name; } if (business.MembershipLevel != null) { viewModel.MembershipLevel = business.MembershipLevel.Name; } return(View(viewModel)); } //Message return(RedirectToAction("Index", "Business")); } }
private ActionResult RejectNewDetails(int id, BusinessViewModel collection) { var model = _businessService.GetById(id); model.LastEntityData = null; _businessService.Update(model); var settings = new JsonSerializerSettings().AddSqlConverters(); settings.NullValueHandling = NullValueHandling.Ignore; var json = JsonConvert.SerializeObject(model, settings); if (model.Location != null) { json = json.Insert(json.Length - 1, ",\"Location\":{\"Lat\":" + model.Location.Lat + ",\"Lng\":" + model.Location.Long + "}"); } var activity = new Activity { ActionTypeId = (byte)GeneralEnums.ActionType.Reject, CreatorId = LogedInAdmin.Id, EntityId = id, ParentId = collection.ActivityId, EntityTypeId = (byte)GeneralEnums.EntityType.Business, Data = "{\"Business\":" + json + "}" }; _activityService.Insert(activity); return(RedirectToAction("Index")); }
public async Task <IActionResult> Post(string categoryName, [FromBody] BusinessViewModel vm) { try { if (ModelState.IsValid) { var newBusiness = Mapper.Map <Business>(vm); var getBusiness = _repository.GetBusinessByName(newBusiness.CompanyName); if (getBusiness == null) { _repository.AddBusiness(categoryName, newBusiness, User.Identity.Name); //Save to the database if (await _repository.SaveChangesAsync()) { return(Created($"/api/category/{categoryName}/business/{newBusiness.CompanyName}", Mapper.Map <BusinessViewModel>(newBusiness))); } } else { //You have tried to put something that already exists _logger.LogError($"El nombre {newBusiness.CompanyName} ya existe, intente denuevo"); return(BadRequest("El nombre que usted introdujo es invalido")); } } } catch (Exception ex) { _logger.LogError($"fallo en guardar nuevo negocio {ex}"); } return(BadRequest("Fallo en guardar negocio negocio ya existe")); }
public FacilityViewModel() { FacilityId = Guid.NewGuid(); Address = new AddressViewModel(); Contact = new ContactViewModel(); Business = new BusinessViewModel(); }
public BusinessViewModel GetBusiness(int bid) { BusinessViewModel businessModel = null; try { var model = businessService.GetBusinessById(bid); if (model != null) { businessModel = new BusinessViewModel(); businessModel.Bid = model.Bid; businessModel.UserId = model.UserId; businessModel.Bname = model.Bname; businessModel.Bphone1 = model.Bphone1; businessModel.Bphone2 = model.Bphone2; businessModel.Bemail = model.Bemail; businessModel.Bwebsite = model.Bwebsite; businessModel.BweeklyHolyday = model.BweeklyHolyday; businessModel.BaccountStartDate = model.BaccountStartDate; return(businessModel); } else { return(businessModel); } } catch (Exception ex) { return(null); } }
public JsonResult getBusiness(string username) { BusinessDAO businessDAO = new BusinessDAO(); var listBusiness = businessDAO.getListBusiness(); var listOfUser = businessDAO.getListBusinessOfUser(username); var list = new List <BusinessViewModel>(); foreach (var item in listBusiness) { var b = new BusinessViewModel(); if (listOfUser.Contains(item)) { b.ID = item.ID; b.Name = item.Name; b.Url = item.Url; b.Status = true; } else { b.ID = item.ID; b.Name = item.Name; b.Url = item.Url; b.Status = false; } list.Add(b); } return(Json(new { username = username, data = list.OrderByDescending(x => x.Status) }, JsonRequestBehavior.AllowGet)); }
public async Task <BusinessViewModel> BusinessById(int id, BPMainContext context) { // we're going to get the business by id var business = await context.Accounts.FindAsync(id); if (business == null) { return(new BusinessViewModel()); } // This business actually exists! var returnModel = new BusinessViewModel { ID = business.ID, Name = business.BusinessAttribute.BusinessName, BusinessType = new NameIdLists { ID = business.BusinessAttribute.BusinessType.ID, Name = business.BusinessAttribute.BusinessType.Name }, Logins = business?.LoginAttribute?.LoginIds.Select(y => new NameIdValueNoteLists { ID = y.ID, Name = y.UserId }) ?? new List <NameIdValueNoteLists>() }; return(returnModel); }
public IActionResult Edit(string id) { var listing = businessRepo.GetById(id); BusinessViewModel vm = populateModel(listing); return(View(vm)); }
public IActionResult Details(string id) { var listing = businessRepo.GetById(id); var vm = new BusinessViewModel(listing); return(View(vm)); }
public ActionResult Business(int?p, string search) { using (UnitOfWorkManager.NewUnitOfWork()) { var pageIndex = p ?? 1; var allBusinesses = string.IsNullOrEmpty(search) ? _businessService.GetAll(pageIndex, SiteConstants.Instance.AdminListPageSize) : _businessService.SearchBusiness(search, pageIndex, SiteConstants.Instance.AdminListPageSize); var listViewModel = new BusinessListViewModel { Businesses = allBusinesses, PageIndex = pageIndex, TotalCount = allBusinesses.TotalCount, Search = search, TotalPages = allBusinesses.TotalPages }; StatesViewModel statesViewModel = new StatesViewModel() { allStates = SettingsService.ListOfStates().ToList() }; var viewModel = new BusinessViewModel { _listViewModel = listViewModel, _stateViewModel = statesViewModel }; return(View(viewModel)); } }
public ActionResult ViewBusiness() { ClearSessionData(); ICustomerVO sessionCustomer = (ICustomerVO)Session["SessionCustomer"]; if (sessionCustomer != null) { IBusinessVO business = BusinessBO.RetrieveBusinessByCustomerId(sessionCustomer.Id); if (business == null) { business = new BusinessVO(); } Session["SessionBusiness"] = business; BusinessViewModel model = (BusinessViewModel)BusinessMapper.Map( business, typeof(IBusinessVO), typeof(BusinessViewModel)); if (string.IsNullOrEmpty(model.CurrentPaidUpCapitalCurrency)) { model.CurrentPaidUpCapitalCurrency = Constants.GetEnumDescription(Currency.SingaporeDollar); } // Needed to do this so that the client validation will not trigger. TempData["BusinessDetailModel"] = model; } return(RedirectToAction("ViewBusinessDetails")); }
public IActionResult BusinessByPostalcode([FromBody] string postalcode) { var model = new BusinessViewModel(); model.Businesses = _orderService.GetBusinesses(postalcode); return(PartialView(model)); }
public CompanyStructureViewModel returndivList() { CompanyStructureViewModel model = new CompanyStructureViewModel(); var listData = _CompanyStructureMethod.getAllDivisionList(); var listbiz = _CompanyStructureMethod.getAllBusinessList(); foreach (var item in listData) { var bizName = _CompanyStructureMethod.getBusinessListById(item.BusinessID); if (bizName != null) { DivisionViewModel tableModel = new DivisionViewModel(); tableModel.Id = item.Id; tableModel.Name = item.Name; tableModel.BusinessName = bizName.Name; tableModel.CreatedDate = item.CreatedDate; tableModel.Archived = item.Archived; model.divisionLists.Add(tableModel); } } foreach (var item in listbiz) { BusinessViewModel tableModel = new BusinessViewModel(); tableModel.Id = item.Id; tableModel.Name = item.Name; tableModel.CreatedDate = item.CreatedDate; tableModel.Archived = item.Archived; model.businessLists.Add(tableModel); } return(model); }
public JsonResult GetBusinesses(BusinessViewModel bViewModel) { PaginationInfo pager = new PaginationInfo(); pager = bViewModel.Pager; PaginationViewModel pViewModel = new PaginationViewModel(); try { pViewModel.dt = _bRepo.GetBusinesses(bViewModel.Business.BusinessName, ref pager); pViewModel.Pager = pager; Logger.Debug("Business Controller GetBusinesses"); } catch (Exception ex) { bViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01")); Logger.Error("Business Controller - GetBusinesses" + ex.ToString()); } return(Json(JsonConvert.SerializeObject(pViewModel), JsonRequestBehavior.AllowGet)); }
public ActionResult Businesses(int id, BusinessViewModel collection) { var request = new FilteredModel <Facility> { PageIndex = collection.ThisPageIndex, Order = collection.PageOrder, OrderBy = collection.PageOrderBy }; var offset = (request.PageIndex - 1) * request.PageSize; var result = _mapper.Map <IList <BusinessViewModel> >(_businessService.GetPagingByFacilityId(id, _mapper.Map <Business>(collection), out long totalCount, request.OrderBy, request.Order, offset, request.PageSize)); if (!result.Any() && totalCount > 0 && request.PageIndex > 1) { request.PageIndex = (int)(totalCount / request.PageSize); if (totalCount % request.PageSize > 0) { request.PageIndex++; } result = _mapper.Map <IList <BusinessViewModel> >(_businessService.GetPagingByFacilityId(id, _mapper.Map <Business>(collection), out totalCount, request.OrderBy, request.Order, offset, request.PageSize)); } ViewBag.OnePageOfEntries = new StaticPagedList <BusinessViewModel>(result, request.PageIndex, request.PageSize, (int)totalCount); ViewBag.SearchModel = collection; ViewBag.Id = id; return(View()); }
// PUT: api/business/5 public IHttpActionResult Put(long?id, FieldType type, [FromBody] BusinessViewModel model) { try { if (!id.HasValue) { return(Ok(new { status = false, data = "", message = "Please provide a valid id." })); } else { var business = _db.tblBusinesses.Find(id); if (business != null) { if (type == FieldType.All) { business.Name = model.Name; business.ShortName = model.ShortName; business.IsInternational = model.IsInternational; business.FaxNumbers = model.FaxNumbers; business.PhoneNumbers = model.PhoneNumbers; business.Logo = model.Logo; business.Add1 = model.Add1; business.Add2 = model.Add2; business.City = model.City; business.State = model.State; business.CountryId = model.CountryId; business.Email = model.Email; business.Website = model.Website; business.Zip = model.Zip; business.MembershipId = model.MembershipId; business.BusinessCategoryId = model.BusinessCategoryId; business.TimezoneId = model.TimezoneId; } else if (type == FieldType.Membership) { business.MembershipId = model.MembershipId; } _db.Entry(business).State = EntityState.Modified; var response = _db.SaveChanges(); if (response > 0) { return(Ok(new { status = true, data = business, message = "Success" })); } else { return(Ok(new { status = false, data = "", message = "There was a problem to update the data." })); } } else { return(Ok(new { status = false, data = "", message = "Not a valid data to update. Please provide a valid id." })); } } } catch (Exception ex) { return(BadRequest(ex.Message.ToString())); } }
public ActionResult Details(int id, BusinessViewModel collection) { try { if (id > 0) { collection.UpdaterId = LogedInAdmin.Id; _businessService.Delete(_mapper.Map <Business>(collection)); return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, GeneralMessages.EmptyId); } catch (Exception ex) { _logger.Error(ex); if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource)) { ModelState.AddModelError(string.Empty, ex.Message); } else { ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError); } } return(View(collection)); }
public BusinessViewModel GetAccountInfoBy(string Email) { StringBuilder sb = new StringBuilder(); sb.Append("SELECT [PasswordHash]"); sb.Append("FROM [dbo].[AspNetUsers]"); sb.Append("WHERE [Email] = '" + Email + "'"); String sql = sb.ToString(); BusinessViewModel bus = new BusinessViewModel(); using (SqlConnection connection = new SqlConnection(DataSettings.CONNECTION_STRING)) { connection.Open(); using (SqlCommand command = new SqlCommand(sql, connection)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { bus.Password = DatabaseHelper.CheckNullString(reader, 0); } } } } return(bus); }
public bool ReadIsApproved(string email) { bool isApproved = false; StringBuilder sb = new StringBuilder(); sb.Append("SELECT [Approved]"); sb.Append("FROM [careerfair].[business]"); sb.Append("WHERE [Email] = '" + email + "'"); String sql = sb.ToString(); BusinessViewModel bus = new BusinessViewModel(); using (SqlConnection connection = new SqlConnection(DataSettings.CONNECTION_STRING)) { connection.Open(); using (SqlCommand command = new SqlCommand(sql, connection)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { isApproved = DatabaseHelper.CheckNullBool(reader, 0); } } } } return(isApproved); }
public BusinessViewModel CreateViewModel(int id) { var businessDetails = GetSiteById(id); BusinessViewModel businessViewModel = new BusinessViewModel(); if (businessDetails != null) { businessViewModel.Id = businessDetails.Id; businessViewModel.BusinessName = businessDetails.BusinessName; businessViewModel.LastSubscribedDate = businessDetails.LastSubscribedDate; businessViewModel.LastExpirationDate = businessDetails.LastExpirationDate; businessViewModel.AddressLine1 = businessDetails.AddressLine1; businessViewModel.AddressLine2 = businessDetails.AddressLine2; businessViewModel.AddressLine3 = businessDetails.AddressLine3; businessViewModel.City = businessDetails.City; businessViewModel.Postcode = businessDetails.Postcode; businessViewModel.ContactPerson = businessDetails.ContactPerson; businessViewModel.ContactEmail = businessDetails.ContactEmail; businessViewModel.ContactPhone = businessDetails.ContactPhone; businessViewModel.IdentityUserId = businessDetails.IdentityUserId; businessViewModel.NotifyWeekly = businessDetails.NotifyWeekly; businessViewModel.DmdAmp = businessDetails.DmdAmp; businessViewModel.DmdAmpp = businessDetails.DmdAmpp; businessViewModel.DmdVmp = businessDetails.DmdVmp; businessViewModel.DmdVmpp = businessDetails.DmdVmpp; businessViewModel.DmdVtm = businessDetails.DmdVtm; businessViewModel.DmdForm = businessDetails.DmdForm; businessViewModel.DmdGtin = businessDetails.DmdGtin; businessViewModel.DmdRoute = businessDetails.DmdRoute; businessViewModel.DmdSupplier = businessDetails.DmdSupplier; } return(businessViewModel); }
public CompanyStructureViewModel returndfunList() { CompanyStructureViewModel model = new CompanyStructureViewModel(); var listfun = _CompanyStructureMethod.getAllFunctionsList(); var listData = _CompanyStructureMethod.getAllDivisionList(); var listbiz = _CompanyStructureMethod.getAllBusinessList(); foreach (var item in listfun) { var bizsName = _CompanyStructureMethod.getBusinessListById((int)item.BusinessID); if (bizsName != null) { var divName = _CompanyStructureMethod.getDivisionById(item.DivisionID); if (divName != null) { FunctionViewModel tablepool = new FunctionViewModel(); tablepool.Id = item.Id; tablepool.Name = item.Name; tablepool.DivisionName = divName.Name; tablepool.BusinessName = bizsName.Name; tablepool.CreatedDate = item.CreatedDate; model.functionLists.Add(tablepool); } else { FunctionViewModel tablepool = new FunctionViewModel(); tablepool.Id = item.Id; tablepool.Name = item.Name; tablepool.DivisionName = ""; tablepool.BusinessName = bizsName.Name; tablepool.CreatedDate = item.CreatedDate; model.functionLists.Add(tablepool); } } } foreach (var item in listData) { DivisionViewModel tableModel = new DivisionViewModel(); tableModel.Id = item.Id; tableModel.Name = item.Name; tableModel.BusinessID = item.BusinessID; tableModel.CreatedDate = item.CreatedDate; tableModel.Archived = item.Archived; model.divisionLists.Add(tableModel); } foreach (var item in listbiz) { BusinessViewModel tableModel = new BusinessViewModel(); tableModel.Id = item.Id; tableModel.Name = item.Name; tableModel.CreatedDate = item.CreatedDate; tableModel.Archived = item.Archived; model.businessLists.Add(tableModel); } return(model); }
public business ToModel(BusinessViewModel b) { return(new business { BusinessID = b.BusinessID, Email = b.Email, BusinessName = b.BusinessName, FirstName = b.FirstName, LastName = b.LastName, Street = b.Street, City = b.City, State = b.State, Zip = b.Zip, Phone = b.Phone, Alumni = b.Alumni, NonProfit = b.NonProfit, Outlet = b.Outlet, Display = b.Display, DisplayDescription = b.DisplayDescription, Attendees = b.Attendees, BusinessDescription = b.BusinessDescription, Website = b.Website, SocialMedia = b.SocialMedia, Photo = b.Photo, LocationPreference = b.LocationPreference, ContactMe = b.ContactMe, PreferEmail = b.PreferEmail, Approved = b.Approved, Active = b.Active, Fields = b.Fields, Positions = b.Positions }); }
public ProducerViewModel(Producer producer) { Address = new AddressViewModel(producer.Address); AreMultiple = producer.AreMultiple; Business = new BusinessViewModel(producer.BusinessName); Contact = new ContactViewModel(producer.Contact); IsAddedToAddressBook = producer.IsAddedToAddressBook; }
public ActionResult DeleteConfirmed(int id) { BusinessViewModel businessViewModel = db.BusinessViewModels.Find(id); db.BusinessViewModels.Remove(businessViewModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ImporterViewModel(Importer importer) { Address = new AddressViewModel(importer.Address); Business = new BusinessViewModel(importer.BusinessName, importer.RegistrationNumber); Contact = new ContactViewModel(importer.Contact); BusinessType = importer.Type; IsAddedToAddressBook = importer.IsAddedToAddressBook; }
private ActionResult AcceptNewDetails(int id, BusinessViewModel collection) { try { if (!ModelState.IsValid) { foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { ModelState.AddModelError(string.Empty, error.ErrorMessage); } } return(View(collection)); } collection.UpdaterId = LogedInAdmin.Id; var model = _mapper.Map <Business>(collection); model.LastEntityData = null; var updateResult = _businessService.Update(model); if (updateResult < 1) { ModelState.AddModelError(string.Empty, GeneralMessages.ErrorInSave); return(View(collection)); } var settings = new JsonSerializerSettings().AddSqlConverters(); settings.NullValueHandling = NullValueHandling.Ignore; var json = JsonConvert.SerializeObject(model, settings); if (model.Location != null) { json = json.Insert(json.Length - 1, ",\"Location\":{\"Lat\":" + model.Location.Lat + ",\"Lng\":" + model.Location.Long + "}"); } var activity = new Activity { ActionTypeId = (byte)GeneralEnums.ActionType.Accept, CreatorId = LogedInAdmin.Id, EntityId = id, ParentId = collection.ActivityId, EntityTypeId = (byte)GeneralEnums.EntityType.Business, Data = "{\"Business\":" + json + "}" }; _activityService.Insert(activity); return(RedirectToAction("Index")); } catch (Exception ex) { _logger.Error(ex); if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource)) { ModelState.AddModelError(string.Empty, ex.Message); } else { ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError); } } return(View(collection)); }