public ActionResult Create([DataSourceRequest] DataSourceRequest request, CompanyViewModel model) { if (this.ModelState.IsValid && model != null) { int id = this.companyService.Create(model.Name, model.ContactId); model = this.companyService .GetById(id) .To<CompanyViewModel>() .FirstOrDefault(); } return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult CreateCompany(PagingFilteringViewModel model) { ViewBag.Title = "Создание компании"; ViewBag.Page = model.Page; ViewBag.SortByname = model.SortByname; ViewBag.SortBycountry = model.SortBycountry; ViewBag.IncludesAdmins = model.IncludesAdmins; if (model.SearchByName != null && model.SearchByName.Trim() == "") { model.SearchByName = null; } ViewBag.SearchByName = model.SearchByName; CompanyViewModel companyViewModel = new CompanyViewModel(); return(View("CompanyView", companyViewModel)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CompanyViewModel company = db.Companies .ProjectTo <CompanyViewModel>() .SingleOrDefault(c => c.ID == id); if (company == null) { return(HttpNotFound()); } return(View(company)); }
// GET: Company/Edit/5 public ActionResult Edit(int id) { HttpResponseMessage responseMsg = ConsumeWebAPI.WebApiClient.GetAsync("Companies/" + id.ToString()).Result; CompanyViewModel ObjCompanyViewModel = null; try { ObjCompanyViewModel = responseMsg.Content.ReadAsAsync <CompanyViewModel>().Result; } catch (Exception ex) { throw; } return(View(ObjCompanyViewModel)); }
public IActionResult Index() { var company = _db.Companies.First(x => x.ID == _userService.User.CompanyID); var kitchens = _db.Kitchens.Where(x => x.CompanyID == company.ID && x.Archived == false).ToList(); var u = _db.Users.Single(x => x.Admin == true && x.CompanyID == company.ID); var vm = new CompanyViewModel() { Compnay = company, Kitchens = kitchens, owner = u.FirstName + u.LastName, userCount = _db.Users.Count(x => x.CompanyID == company.ID && x.Archived == false) }; return(View(vm)); }
public CompanyViewModel CompanyRegister(CompanyViewModel newCompany) { CompanyViewModel result = new CompanyViewModel(); try { PractitionerData dataLayer = new PractitionerData(); result = dataLayer.CreateCompany(newCompany); } catch (Exception err) { new LogHelper().LogMessage("PractitionerBusiness.CompanyRegister : " + err); } return(result); }
public HttpResponseMessage UpdateCompany([FromBody] CompanyViewModel model) { try { var data = companyrepository.UpdateCompanyDetails(model); if (data != null) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, Result = model, Message = "The record Updated Successfully" })); } return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = " There was an Error updating the record" })); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = $"There was an Error updating the record { ex.Message }" })); } }
public async Task <IActionResult> CreateValidation(CompanyViewModel viewModel) { var companyModel = new CompanyModel() { CompanyName = viewModel.CompanyName, TableName = viewModel.TableName }; var tableFirstToUpper = companyModel.TableName.First().ToString().ToUpper() + companyModel.TableName.Substring(1); excelList = await this.readExcelService.ReadExcel($@"{this.filePath}\Forms.xlsx", $"{tableFirstToUpper}"); var validationSQL = this.validationCreationService.CreateValidationSQL(this.filePath, excelList, companyModel); this.sQLFileCreationService.CreateSQLFile($@"{filePath}\GeneratedValidation", validationSQL, companyModel.CompanyName, $"{companyModel.TableName}-validation"); return(View()); }
public async Task <IActionResult> Create([Bind("Id,CompanyName,CreatedDate")] CompanyViewModel company) { if (ModelState.IsValid) { Company com = new Company() { CompanyName = company.CompanyName, CreatedDate = company.CreatedDate }; //_context.Add(company); await companyRepository.SaveCompany(com); return(RedirectToAction(nameof(Index))); } return(View(company)); }
public IActionResult Login([FromBody] Company login) { IActionResult response = Unauthorized(); CompanyViewModel company = AuthenticateUser(login); if (company != null) { var tokenString = GenerateJWT(company); response = Ok(new { token = tokenString, userDetails = company }); } return(response); }
public async Task Update(CompanyViewModel companyVm) { var query = await _asyncRepository.GetByIdAsync(companyVm.Id); if (query == null) { throw new ArgumentNullException(nameof(CompanyViewModel)); } query.Name = companyVm.Name; query.Address = companyVm.Address; query.HotLine = companyVm.HotLine; await _asyncRepository.UpdateAsync(query); await _asyncRepository.unitOfWork.SaveChangesAsync(); }
public void Insert_ExistingObject_ReturnsTrue() { CompanyViewModel item = new CompanyViewModel() { Id = 1, Name = "Test", Description = "Test", PhoneId = 2, TariffId = 1, Type = CompanyType.Send, ApplicationGroupId = 2, IsPaused = false }; mockMapper.Setup(m => m.Map <CompanyViewModel, Company>(item)) .Returns(new Company() { Id = 1, Name = "Test", Description = "Test", PhoneId = 2, TariffId = 1, Type = CompanyType.Send, ApplicationGroupId = 2, IsPaused = false }); var result = manager.Insert(item); Assert.IsFalse(result); }
public async Task <ActionResult> Create(CompanyViewModel vm) { var result = await _companyServices.Create(vm, GetAccount()); if (result.Status == Status.ok) { return(RedirectToAction(nameof(Index))); } else { ModelState.AddModelError("", "保存失败: " + result.Message); await Init(vm); return(View(vm)); } }
public async Task <IActionResult> Edit(CompanyViewModel model) { if (ModelState.IsValid) { Company company = new Company() { Id = model.Id, Name = model.Name }; _dbContext.Companies.Update(company); await _dbContext.SaveChangesAsync(); return(RedirectToAction(nameof(List))); } return(View()); }
public async Task <IActionResult> Edit(int id) { var data = await _dbContext.Companies.FindAsync(id); if (data == null) { return(Redirect("/Home/Error")); } CompanyViewModel model = new CompanyViewModel() { Id = data.Id, Name = data.Name }; return(View(model)); }
public async Task <ActionResult <CompanyViewModel> > GetById(int id) { if (id < 1) { return(NotFound(new { Message = "Company not found" })); } Company company = await _companyRepository.GetById(id); if (company == null) { return(NotFound(new { Message = "Candidate not found" })); } CompanyViewModel companyModel = _mapper.Map <CompanyViewModel>(company); return(Ok(companyModel)); }
public IActionResult Index() { //CompanyList = CompanyDB.Instance.GetCompanyList(), var returnModel = new CompanyViewModel() { CompanyTypeList = CompanyTypeDB.GetInstance().GetAllCompanyTypes(), CompanyList = CompanyDB.GetInstance().GetAllCompaniesForAdminPanel(userObj), Platforms = PlatformDB.GetInstance().GetAllPlatforms(), Sectors = SectorDB.GetInstance().GetAllSectors(), /*Users = UserDB.GetInstance().GetAllUsers(),*/ Distributors = DistributorDB.GetInstance().GetAllDistributors(userObj), CompanyPartners = CompanyPartnerDB.GetInstance().GetAllCompanyPartners() }; return(View(returnModel)); }
public ActionResult <List <CompanyViewModel> > List() { var res = _bo.List(); if (!res.Success) { return(InternalServerError()); } var list = new List <CompanyViewModel>(); foreach (var item in res.Result) { list.Add(CompanyViewModel.Parse(item)); } return(list); }
private ContactViewModel CreateContactViewModel() { CompanyViewModel companyViewModel = _fixture.Build <CompanyViewModel>() .With(m => m.PrimaryPhone, _fixture.Create <string>()) .With(m => m.SecondaryPhone, _fixture.Create <string>()) .Create(); return(_fixture.Build <ContactViewModel>() .With(m => m.ContactType, _random.Next(100) > 50 ? ContactType.Company : ContactType.Person) .With(m => m.PrimaryPhone, _fixture.Create <string>()) .With(m => m.SecondaryPhone, _fixture.Create <string>()) .With(m => m.HomePhone, _fixture.Create <string>()) .With(m => m.MobilePhone, _fixture.Create <string>()) .With(m => m.Company, companyViewModel) .Create()); }
public string PostNewCompany(CompanyViewModel companyDetails) { return(_companyRepository.Insert(new Company() { CompanyId = companyDetails.CompanyId, CompanyName = companyDetails.CompanyName, AddressLine1 = companyDetails.AddressLine1, AddressLine2 = companyDetails.AddressLine2, City = companyDetails.City, State = companyDetails.State, Zipcode = companyDetails.Zipcode, Country = companyDetails.Country, Phone = companyDetails.Phone, Email = companyDetails.Email, })); }
public IHttpActionResult PostCompany(CompanyViewModel company) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (companyService.AddCompany(company)) { return(Ok(company)); } else { return(Content(HttpStatusCode.BadRequest, "Company already exists")); } }
public CompanyViewModel ViewCompanyProfile(CompanyViewModel company) { CompanyViewModel result = new CompanyViewModel(); if (company != null) { PatientBusiness businessLayer = new PatientBusiness(); result = businessLayer.ViewCompanyProfile(company.CompanyId); } else { return(null); } return(result); }
public JsonResult GetCompanyById(int Id) { if (Id > 0) { Company c = repository.Company.GetNotDeletedItems().First(j => j.Id == Id); CompanyViewModel result = new CompanyViewModel(new CompanyExportFromDatabase() { company = c, legal_form_type = c.LegalFormType, addr = c.ActualAddr }); return(Json(result, JsonRequestBehavior.AllowGet)); } else { return(Json(new CompanyViewModel(), JsonRequestBehavior.AllowGet)); } }
// GET: Companies/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } _companyModelService = IoCInit.GetScope().Resolve <ICompanyModelService>(); FoundCompany = _companyModelService.SearchByCompanyId(Convert.ToInt32(id)); if (FoundCompany == null) { return(HttpNotFound()); } return(View(FoundCompany)); }
/// <summary> /// Method for inserting new company to db /// </summary> /// <param name="item">ViewModel of Company</param> /// <param name="groupId">Id of Group wich create this company</param> public bool Insert(CompanyViewModel item) { Company company = mapper.Map <CompanyViewModel, Company>(item); try { unitOfWork.Companies.Insert(company); notificationsGenerator.SupplyWithCampaignNotifications(company); unitOfWork.Save(); } catch (Exception) { return(false); } return(true); }
public ActionResult AddCompanyReview(CompanyViewModel companyModel) { try { //Get the Database Context ExploreDbContext dbContext = new ExploreDbContext(); // Create Company CompanyModel newCompany = new CompanyModel() { companyname = companyModel.CompanyName, location = companyModel.Lat + "," + companyModel.Long, overallrating = companyModel.rating, id = Guid.NewGuid().ToString() }; newCompany = dbContext.Company.Add(newCompany); // Create Job Position PositionModel newPosition = new PositionModel() { id = Guid.NewGuid().ToString(),companyid = newCompany.id, overallrating = companyModel.rating, positionname = companyModel.PositionName }; newPosition = dbContext.AddPositionModel(newPosition); //Create Job Review ReviewModel newReview = new ReviewModel() { id = Guid.NewGuid().ToString(), createddate = DateTime.Now,dislikes = 0, likes=0, reviewmessage = companyModel.review, overallrating = companyModel.rating,UserId = User.Identity.GetUserId(), PositionId = newPosition.id,totalreview = 1 }; newReview = dbContext.AddReviewModel(newReview); dbContext.SaveChanges(); } catch (Exception ex) { //Suppress Exception } return RedirectToActionPermanent("Index"); }
public int CreateNewCompany(CompanyViewModel newCompany) { PractitionerBusiness businessLayer = new PractitionerBusiness(); if (newCompany != null) { CompanyViewModel result = businessLayer.CompanyRegister(newCompany); if (result.ConflictEmailAddress == 1) { return(2); } if (result != null) { try { //Sending verification email to admin to verify string mailFrom = ConstantHelper.AppSettings.MailFrom; string adminMail = ConstantHelper.AppSettings.AdminEmail; string emailSubject = ConstantHelper.Email.CompanyVerification.EmailSubject; string emailBody = ConstantHelper.Email.CompanyVerification.EmailBody; string linkToApprove = ConstantHelper.AppSettings.BackEndUrl + ConstantHelper.API.Company.CompanyApproved + "?accId=" + result.CompanyId; string linkToReject = ConstantHelper.AppSettings.BackEndUrl + ConstantHelper.API.Company.CompanyRejected + "?accId=" + result.CompanyId; string companyDetailsTable = "<table><tr><th>" + "Company Name" + "</th><td>" + result.CompanyName + "</td></tr><tr><th>" + "Company Phone Number" + "</th><td>" + result.CompanyPhoneNumber + "</td></tr><tr><th>" + "Company Email Address" + "</th><td>" + result.CompanyEmailAddress + "</td></tr><tr><th rowspan='3'>" + "Company Address" + "</th><td>" + result.CompanyAddressLine1 + "</td></tr><tr><td>" + result.CompanyAddressLine2 + "</td></tr><tr><td>" + result.CompanyAddressLine3 + "</td></tr></table>"; emailBody = emailBody.Replace(ConstantHelper.Email.Keyword.LinkToApprove, linkToApprove); emailBody = emailBody.Replace(ConstantHelper.Email.Keyword.LinkToReject, linkToReject); emailBody = emailBody.Replace(ConstantHelper.Email.Keyword.companyDetailsTable, companyDetailsTable); string userName = ConstantHelper.AppSettings.UserName; string password = ConstantHelper.AppSettings.Password; EmailHelper.SentMail(mailFrom, adminMail, emailSubject, emailBody, userName, password); //Notify company string emailBodyForCompany = ConstantHelper.Email.CompanyVerification.CompanyEmailBody; EmailHelper.SentMail(mailFrom, result.CompanyEmailAddress, emailSubject, emailBodyForCompany, userName, password); } catch (Exception err) { new LogHelper().LogMessage("RegistrationController.CreateNewCompany : " + err); } return(1); } } return(0); }
public ActionResult Company() { try { Session["calledPage"] = "C"; string companyName = Convert.ToString(Request.Url.Segments[2]).Trim(); CompanyViewModel companyViewModel = null; if (companyName != string.Empty) { Session["CompanyName"] = companyName; } if (CacheHandler.Exists(companyName.ToLower())) { companyViewModel = new CompanyViewModel(); CacheHandler.Get(companyName.ToLower(), out companyViewModel); } else { CompanyFilterEntity companyFilter = new CompanyFilterEntity { CompanyName = companyName.Replace("-", " "), MinRate = 0, MaxRate = 0, MinEmployee = 0, MaxEmployee = 0, SortBy = "DESC", FocusAreaID = 0, Location = "0", SubFocusArea = "0", UserID = Convert.ToInt32(Session["UserID"]), PageNo = 1, PageSize = 10, OrderColumn = 1 }; companyViewModel = new CompanyService().GetCompany(companyFilter); CacheHandler.Add(companyViewModel, companyName); } companyViewModel.WebBaseURL = _webBaseURL; return(View(companyViewModel)); } catch (Exception) { return(null); } }
public ActionResult AddCompanies(int id = 0) { if (id == 0) { CompanyViewModel model = new CompanyViewModel(); CommonRepository objCommonRepository = new CommonRepository(); model.Cities = objCommonRepository.GetCities(true, null, "Select"); return(View(model)); } else { CompanyViewModel model = new CompanyViewModel(); CompanyRepository repository = new CompanyRepository(); model = repository.GetCompanyByID(id); return(View(model)); } }
public CompaniesController(ApplicationDbContext context) { _context = context; CompanyViewModel = new CompanyViewModel() { Company = new Company(), Customers = _context.Customers.ToList(), Countries = _context.Countries.ToList(), Cities = _context.Cities.ToList(), CompanyTypes = _context.CompanyTypes.ToList(), CompaniesTypes = _context.CompaniesTypes.ToList() }; CompanyViewModel.CustomersNames = CompanyViewModel.Customers.Select(c => new FullName() { Id = c.Id, Name = c.FirstName + " " + c.LastName }); }
public ActionResult CreateCompany(CompanyViewModel model) { List <string> errors = new List <string>(); try { if (ModelState.IsValid) { if (model.Id == 0) { return(RedirectToAction("companydetail")); } else { var oldmodel = db.CompanyRepo.GetById(model.Id); if (oldmodel == null) { Response.StatusCode = (int)HttpStatusCode.OK; return(Json(new { redirecturl = "/error/badrequest" })); } oldmodel.Name = model.Name; oldmodel.Address = model.Address; oldmodel.EmailAddress = model.EmailAddress; oldmodel.SubTitle1 = model.SubTitle1; oldmodel.SubTitle2 = model.SubTitle2; oldmodel.SubTitle3 = model.SubTitle3; oldmodel.SubTitle4 = model.SubTitle4; oldmodel.Phone = model.Phone; } db.SaveChanges(); Response.StatusCode = (int)HttpStatusCode.OK; TempData["Success"] = "Company Details Successfully Updated"; return(RedirectToAction("companydetail")); } foreach (var item in ModelState.Where(x => x.Value.Errors.Any())) { errors.Add(item.Value.Errors.FirstOrDefault().ErrorMessage); } } catch (Exception ex) { errors.Add(ex.GetExceptionMessages()); } Response.StatusCode = (int)HttpStatusCode.SeeOther; return(View(model)); }
public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, CompanyViewModel model) { this.companyService.Delete(model.Id); return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public async Task<ActionResult> Edit(int? id, CompanyViewModel companyViewModel, HttpPostedFileBase uploadFile) { var company = _db.Companies.Find(id); Mapper.Map(companyViewModel, company); if (!ModelState.IsValid) return View(company); string categories = ";"; foreach (var categorie in Categories) { if (Request.Form[categorie] == "on") { categories += categorie + ";"; } } company.Categories = categories; if (uploadFile != null && uploadFile.ContentLength > 0) { using (var reader = new BinaryReader(uploadFile.InputStream)) { var imageFile = reader.ReadBytes(uploadFile.ContentLength); //TODO //Upload image file to Azure Blobs and get url to index it } //TODO //Save de url in the Logo field company.Logo = Path.GetFileName(uploadFile.FileName); } //_db.Entry(company).State = EntityState.Modified; await _db.SaveChangesAsync(); return RedirectToAction("Index"); }