Exemple #1
0
        public async Task <IActionResult> Edit(EditCompanyViewModel editCompanyViewModel, IFormFile LoadedFile)
        {
            ViewData["CurrentTitle"] = "Index";
            if (ModelState.IsValid)
            {
                Company company = await db.Companies.FirstOrDefaultAsync(i => i.Id == editCompanyViewModel.Id);

                company.Name         = editCompanyViewModel.Name;
                company.BrieflyAbout = editCompanyViewModel.BrieflyAbout;
                company.About        = editCompanyViewModel.About;
                if (editCompanyViewModel.Video != "")
                {
                    company.Video = editCompanyViewModel.Video;
                }

                if (await SaveImgAsync(LoadedFile, "Logo", editCompanyViewModel.OwnerName))
                {
                    company.Logo = GetPathImg(LoadedFile.FileName, "Logo", editCompanyViewModel.OwnerName);
                }
                db.Companies.Update(company);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", "Home"));
            }
            return(Redirect("Edit?id=" + editCompanyViewModel.Id));
            //return View(editCompanyViewModel);
        }
Exemple #2
0
        public async Task <ActionResult> EditCompany(long id, [FromBody] EditCompanyViewModel model)
        {
            var command = new EditCompanyCommand(id, model.Name, model.EstablishmentYear, model.Employees);
            var result  = await this.mediator.Send(command);

            return(NoContent());
        }
Exemple #3
0
        public async Task <IActionResult> Edit(int id)
        {
            var company = this.companiesService.GetById <EditCompanyViewModel>(id);

            if (company == null)
            {
                return(this.BadRequest());
            }

            var user = await this.userManager.GetUserAsync(this.User);

            if (!this.User.IsInRole(GlobalConstants.AdministratorRoleName) && user.Id != company.UserId)
            {
                return(this.Unauthorized());
            }

            var categories = this.categoriesService.GetAll <CategoryDropdownViewModel>();

            var viewModel = new EditCompanyViewModel
            {
                UserId       = company.UserId,
                Description  = company.Description,
                Name         = company.Name,
                CategoryId   = company.CategoryId,
                OfficialSite = company.OfficialSite,
                LogoImage    = company.LogoImage,
                Categories   = categories,
            };

            return(this.View(viewModel));
        }
        public int Update(EditCompanyViewModel model)
        {
            var result = new CompanyModel();

            result.Phoneid     = model.Phoneid;
            result.com_country = model.com_country;
            result.Com_name    = model.Com_name;
            result.isActive    = true;
            if (model.Photo != null)
            {
                if (model.Existingphotopath != null)
                {
                    string filepath = Path.Combine(hostingEnvironment.WebRootPath, "Image", model.Existingphotopath);
                    System.IO.File.Delete(filepath);
                }
                result.com_Logo = util.ProcessPhotoproperty(model.Photo);
            }
            else
            {
                result.com_Logo = model.Existingphotopath;
            }
            context.Entry(result).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(result.Phoneid);
        }
        public ActionResult EditCompany(string companyIdentificator)
        {
            var company = _context.companyRepository.GetCompanyById(companyIdentificator);
            EditCompanyViewModel companyToUpdate = _mapper.Map <EditCompanyViewModel>(company);

            return(View(companyToUpdate));
        }
        public ActionResult EditCompany(EditCompanyViewModel editedCompany)
        {
            if (ModelState.IsValid)
            {
                Company company = _mapper.Map <Company>(editedCompany);
                _context.companyRepository.UpdateCompany(company);

                #region EntityLogs

                var logInfoUpdateCompany = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["updateCompany"]);
                _logger.AddCompanyLog(company, logInfoUpdateCompany);

                #endregion

                #region PersonalUserLogs

                var logInfoPersonalUpdateCompany = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["updateCompany"], "Nazwa przedsiębiorstwa: " + company.CompanyName);
                _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalUpdateCompany);

                #endregion

                return(RedirectToAction("ConfirmationOfActionOnCompany", "Companies", new { companyIdentificator = editedCompany.CompanyIdentificator, TypeOfAction = "Update" }));
            }

            return(View(editedCompany));
        }
        public async Task <IActionResult> Edit(EditCompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                var company = await _dataContext.Companies
                              .Include(o => o.User)
                              .Include(ct => ct.CompanyType)
                              .FirstOrDefaultAsync(o => o.Id == model.Id);

                var companyType = await _dataContext.CompanyTypes.FirstOrDefaultAsync(o => o.Id == model.CompanyTypeId);


                company.User.Document    = model.Document;
                company.User.FirstName   = model.FirstName;
                company.User.LastName    = model.LastName;
                company.User.Address     = model.Address;
                company.User.PhoneNumber = model.PhoneNumber;

                company.GRXX        = model.GRXX;
                company.GRYY        = model.GRYY;
                company.Name        = model.Name;
                company.CompanyType = companyType;



                _dataContext.Companies.Update(company);
                await _dataContext.SaveChangesAsync();

                await _userHelper.UpdateUserAsync(company.User);

                return(RedirectToAction(nameof(Index)));
            }

            return(View(model));
        }
        public ActionResult EditCompany(EditCompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Id == 0)
                {
                    model.Id = (int)TempData["compID"];
                }

                Company c = new Company
                {
                    Id       = model.Id,
                    Name     = model.Name,
                    Location = model.Location,
                    Sector   = model.Sector,
                    Package  = model.Package
                };

                CompanyRepo.Update(c);
                CompanyRepo.SaveChanges();

                //saves bool in tempdata to force a refresh of context and repositories in panel action,
                //else it will retrieve old data from the database instead of the updated data.
                TempData["UpdateHappened"] = true;
                return(RedirectToAction("EhvPanel", "Home"));
            }

            TempData["ViewD"] = ViewData;
            return(RedirectToAction("Edit", "Company"));
        }
Exemple #9
0
        public IActionResult Update(int id, EditCompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                var company = _databaseContext.Companies.Include(g => g.Users).First(g => g.Id == id);
                company.City        = _databaseContext.Cities.ToList().First(c => c.Id == model.CityId);
                company.Name        = model.Company.Name;
                company.Address     = model.Company.Address;
                company.Description = model.Company.Description;
                company.Logo        = model.Company.Logo;
                company.Website     = model.Company.Website;

                TempData["Success"] = true;
                company.Users.Clear();
                var newUsers = _databaseContext.Users.Where(u => model.UserIds.Contains(u.Id)).ToList();
                foreach (var user in newUsers)
                {
                    company.Users.Add(user);
                }


                _databaseContext.SaveChanges();
            }
            return(RedirectToAction(nameof(Index)));
        }
Exemple #10
0
        public ActionResult EditCompany(EditCompanyViewModel editCompanyViewModel, string id)
        {
            if (ModelState.IsValid)
            {
                TempData["CompanyEdit"]        = "Company Successfully Updated";
                editCompanyViewModel.CompanyId = id;
                _companyService.Update(editCompanyViewModel);
                return(View("Edit", PrepareCompanyEdit(id)));
            }

            return(View("Edit", PrepareCompanyEdit(id)));
        }
        public virtual ActionResult Add()
        {
            var user     = _userByIdQuery.WithUserId(CurrentUserId).Execute();
            var statuses = _serviceFactory.GetService <LeadStatusesAvailableForCompaniesQuery>().Execute();
            var model    = new EditCompanyViewModel
            {
                JobSearchId           = Convert.ToInt32(user.LastVisitedJobSearchId),
                AvailableLeadStatuses = _serviceFactory.GetService <LeadStatusesAvailableForCompaniesQuery>().Execute()
            };

            return(View(MVC.Company.Views.Edit, model));
        }
Exemple #12
0
        public ActionResult Edit(int id)
        {
            Company company = db.Companies.FirstOrDefault(i => i.Id == id);

            if (User.Identity.Name == company.OwnerName || User.IsInRole("admin"))
            {
                EditCompanyViewModel editCompanyViewModel = EditCompanyViewModel.ParseCompanyInViewModel(company);

                return(View(editCompanyViewModel));
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemple #13
0
        public ActionResult Edit(int id)
        {
            var model = new EditCompanyViewModel();

            model.Company = CompanyService.FindCompanyModel(id);
            prepareEditModel(model);

            model.Company = CompanyService.FindCompanyModel(id);
            model.LGS     = CompanyService.LockCompany(model.Company);

            return(View(model));
        }
        public virtual ActionResult Edit(EditCompanyViewModel model)
        {
            Company company;

            try
            {
                // Determine if this is a new company or not
                if (model.Id == 0)
                {
                    company = new CreateCompanyCommand(_serviceFactory).WithJobSearch(model.JobSearchId)
                              .SetName(model.Name)
                              .SetCity(model.City)
                              .SetIndustry(model.Industry)
                              .SetMetroArea(model.MetroArea)
                              .SetNotes(model.Notes)
                              .SetPhone(model.Phone)
                              .SetState(model.State)
                              .SetZip(model.Zip)
                              .SetWebsite(model.Website)
                              .CalledByUserId(CurrentUserId)
                              .Execute();
                }
                else
                {
                    company = new EditCompanyCommand(_serviceFactory).WithCompanyId(model.Id)
                              .SetName(model.Name)
                              .SetCity(model.City)
                              .SetIndustry(model.Industry)
                              .SetMetroArea(model.MetroArea)
                              .SetNotes(model.Notes)
                              .SetPhone(model.Phone)
                              .SetState(model.State)
                              .SetZip(model.Zip)
                              .SetLeadStatus(model.LeadStatus)
                              .SetWebsite(model.Website)
                              .RequestedByUserId(CurrentUserId)
                              .Execute();
                }

                return(RedirectToAction(MVC.Company.Details(company.Id)));
            }

            catch (ValidationException ex)
            {
                foreach (var error in ex.Errors)
                {
                    ModelState.AddModelError(error.PropertyName, error.ErrorMessage);
                }

                model.AvailableLeadStatuses = _serviceFactory.GetService <LeadStatusesAvailableForCompaniesQuery>().Execute();
                return(View(model));
            }
        }
Exemple #15
0
        public ViewResult Edit(int id)
        {
            Company company = _manageEmployment.GetCompany(id);

            EditCompanyViewModel editCompanyViewModel = new EditCompanyViewModel()
            {
                Address      = company.Address,
                CompanyName  = company.CompanyName,
                ContactEmail = company.ContactEmail,
                ContactName  = company.ContactName,
                ContactPhone = company.ContactPhone
            };

            return(View(editCompanyViewModel));
        }
Exemple #16
0
        public ViewResult Edit(int id)
        {
            var company = _databaseContext.Companies.Include(u => u.Users).Include(g => g.City).First(g => g.Id == id);

            ViewData["Success"] = TempData["Success"];
            ViewData["Cities"]  = _databaseContext.Cities.ToList();
            ViewData["Users"]   = _databaseContext.Users.ToList();

            var model = new EditCompanyViewModel
            {
                Company = company,
                CityId  = company.City.Id,
                UserIds = company.Users.ToList().Select(u => u.Id)
            };

            return(View(model));
        }
Exemple #17
0
 public IActionResult Edit(EditCompanyViewModel model)
 {
     if (ModelState.IsValid)
     {
         Company company = _manageEmployment.GetCompany(model.Id);
         {
             company.Address      = model.Address;
             company.CompanyName  = model.CompanyName;
             company.ContactEmail = model.ContactEmail;
             company.ContactPhone = model.ContactPhone;
             company.ContactName  = model.ContactName;
         };
         _manageEmployment.UpdateCompany(company);
         return(RedirectToAction("listcompany"));
     }
     return(View());
 }
Exemple #18
0
        // GET: Company/Edit/5
        public ActionResult Edit(int id)
        {
            var data = icompanyRepositories.GetDetail(id);

            if (data != null)
            {
                EditCompanyViewModel m = new EditCompanyViewModel()
                {
                    com_country       = data.com_country,
                    Com_name          = data.Com_name,
                    Phoneid           = data.Phoneid,
                    Existingphotopath = data.Photopath,
                };
                return(View(m));
            }
            ViewBag.Name = "Company";
            return(View("ProductNotFound", id));
        }
Exemple #19
0
        public IActionResult Edit(EditCompanyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                // if model state is not valid, redirect user to AddCompany page and list validation errors
                return(BadRequest(ModelState));
            }

            var editCompany = mapper.Map <CompanyDTO>(model);

            var message = new EditCompanyMessage {
                Company = editCompany
            };

            var responseMessage = bus.Request <EditCompanyMessage, EditCompanyResponseMessage>(message);

            return(RedirectToAction("Details", "Companies", new { id = responseMessage.Company.Id }));
        }
Exemple #20
0
        public void Update(EditCompanyViewModel editCompanyViewModel)
        {
            var companyToUpdate = _companyRepository.Get(editCompanyViewModel.CompanyId);
            var address         = _addressService.Get(companyToUpdate.AddressId);

            address.BuildingNumber = editCompanyViewModel.BuildingNumber;
            address.StreetName     = editCompanyViewModel.StreetName;
            address.StreetNumber   = editCompanyViewModel.StreetNumber;

            _addressService.Update(address);
            //Update an address
            //companyToUpdate.AddressId = editCompanyViewModel.a
            companyToUpdate.CityId      = editCompanyViewModel.CityId;
            companyToUpdate.ProvinceId  = editCompanyViewModel.ProvinceId;
            companyToUpdate.CompanyName = editCompanyViewModel.CompanyName;
            companyToUpdate.Telephone   = editCompanyViewModel.Telephone;
            _companyRepository.Update(companyToUpdate);
        }
Exemple #21
0
        public async Task <IActionResult> EditCompany(string companyId)
        {
            await GetLoggedInUser();

            var model = new EditCompanyViewModel()
            {
                Company = await _companyService.GetCompanyWithAllIncludePropertiesAsync(new Guid(companyId))
            };

            model.Company.CompanyImageUrl = $"{_pathService.PictureFolder}{model.Company.CompanyImageUrl}";
            model.Company.CompanyLogo     = $"{_pathService.LogoFolder}{model.Company.CompanyLogo}";

            model.Company.TourPackages.ForEach(tp =>
            {
                tp.Spots.Sort((s1, s2) => s1.Name.Length.CompareTo(s2.Name.Length));
            });

            return(View(model));
        }
        public ActionResult Edit(string id)
        {
            if (TempData["ViewD"] != null)
            {
                ViewData = (ViewDataDictionary)TempData["ViewD"];
                return(View());
            }

            //retrieves relevant admin account from tempdata
            User u = (User)TempData["CurrentUser"];

            //and places it back for further use
            TempData["CurrentUser"] = u;

            //gets userId from actionlink ID
            int companyId = Convert.ToInt32(id.Replace("Edit", ""));

            TempData["compID"] = companyId;

            Company c = CompanyRepo.GetById(companyId);

            if (u == null)
            {
                //for testing
                u = new User
                {
                    Role = UserRole.EHVAdmin
                };
            }

            EditCompanyViewModel model = new EditCompanyViewModel
            {
                Id              = c.Id,
                Name            = c.Name,
                Location        = c.Location,
                Sector          = c.Sector,
                Package         = c.Package,
                CurrentUserRole = u.Role
            };

            return(View(model));
        }
Exemple #23
0
        void prepareEditModel(EditCompanyViewModel model)
        {
            PrepareViewModel(model, EvolutionResources.bnrAddEditCompany);
            model.LogoList = MediaServices.FindCompanyLogos();

            model.WarehouseTemplateList        = LookupService.FindDocumentTemplatesListItemModel(DocumentTemplateCategory.PurchaseOrder, DocumentTemplateType.SendPOtoWarehouse);
            model.SupplierTemplateList         = LookupService.FindDocumentTemplatesListItemModel(DocumentTemplateCategory.PurchaseOrder, DocumentTemplateType.SendPOtoSupplier);
            model.FreightForwarderTemplateList = LookupService.FindDocumentTemplatesListItemModel(DocumentTemplateCategory.PurchaseOrder, DocumentTemplateType.SendPOtoFreightForwarder);

            model.LocationList   = LookupService.FindLocationListItemModel(model.Company);
            model.CountryList    = LookupService.FindCountriesListItemModel();
            model.CurrencyList   = LookupService.FindCurrenciesListItemModel();
            model.DateFormatList = LookupService.FindDateFormatListItemModel();

            model.UnitOfMeasureList = new List <ListItemModel>();
            model.UnitOfMeasureList.Add(new ListItemModel(EvolutionResources.lblMetric, ((int)UnitOfMeasure.Metric).ToString()));
            model.UnitOfMeasureList.Add(new ListItemModel(EvolutionResources.lblImperial, ((int)UnitOfMeasure.Imperial).ToString()));

            model.UserList = MembershipManagementService.FindUserListItemModel();
        }
Exemple #24
0
        public async Task <IActionResult> EditCompany(EditCompanyViewModel model)
        {
            if (ModelState.IsValid)
            {
                string imagePath          = _pathService.PictureFolder;
                string physicalUploadPath = _webHostEnvironment.WebRootPath + imagePath;
                string demoImage          = _pathService.DummyCompanyImageUrl;
                model.Company.CompanyImageUrl = await GeneralUtilityMethods.GetSavedImageUrlAsync(model.ImageFile, physicalUploadPath, demoImage);

                imagePath                 = _pathService.LogoFolder;
                physicalUploadPath        = _webHostEnvironment.WebRootPath + imagePath;
                demoImage                 = _pathService.DummyCompanyLogo;
                model.Company.CompanyLogo = await GeneralUtilityMethods.GetSavedImageUrlAsync(model.LogoFile, physicalUploadPath, demoImage);

                await _companyService.EditAsync(model.Company);

                return(RedirectToAction("CompanyPublicView", "Company", new { companyId = model.Company.Id.ToString() }));
            }

            return(View(model));
        }
Exemple #25
0
        //Prevent Code duplication for posting edit and displaying edit
        private EditCompanyViewModel PrepareCompanyEdit(string id)
        {
            var cities               = _cityService.GetAll();
            var provinces            = _provinceService.GetAll();
            var company              = _companyService.Get(id);
            var city                 = _cityService.Get(company.CityId);
            var province             = _provinceService.Get(company.ProvinceId);
            var address              = _addressService.Get(company.AddressId);
            var editCompanyViewModel = new EditCompanyViewModel();

            editCompanyViewModel.Cities         = cities;
            editCompanyViewModel.Provinces      = provinces;
            editCompanyViewModel.BuildingNumber = address.BuildingNumber;
            editCompanyViewModel.StreetName     = address.StreetName;
            editCompanyViewModel.StreetNumber   = address.StreetNumber;
            editCompanyViewModel.Telephone      = company.Telephone;
            editCompanyViewModel.CompanyName    = company.CompanyName;
            editCompanyViewModel.CityId         = company.CityId;
            editCompanyViewModel.ProvinceId     = company.ProvinceId;
            editCompanyViewModel.CompanyId      = company.Id;
            return(editCompanyViewModel);
        }
Exemple #26
0
 public ActionResult Edit(int id, EditCompanyViewModel model)
 {
     try
     {
         // TODO: Add update logic here
         if (ModelState.IsValid)
         {
             var data = icompanyRepositories.GetDetail(id);
             if (data != null)
             {
                 int Phoneid = icompanyRepositories.Update(model);
                 return(RedirectToAction("Details", new { id = Phoneid }));
             }
             ViewBag.Name = "Company";
             return(View("ProductNotFound", id));
         }
         return(View(model));
     }
     catch
     {
         return(View("Error"));
     }
 }
Exemple #27
0
 public ActionResult Save(EditCompanyViewModel model, string command)
 {
     if (command.ToLower() == "save")
     {
         var modelError = CompanyService.InsertOrUpdateCompany(model.Company, CurrentUser, model.LGS);
         if (modelError.IsError)
         {
             prepareEditModel(model);
             model.SetErrorOnField(ErrorIcon.Error,
                                   modelError.Message,
                                   "Company_" + modelError.FieldName);
             return(View("Edit", model));
         }
         else
         {
             return(RedirectToAction("Companies"));
         }
     }
     else
     {
         return(RedirectToAction("Companies"));
     }
 }
        public async Task <IActionResult> Put(long id, [FromBody] EditCompanyViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            if (id != model.Id)
            {
                return(BadRequest());
            }

            var company = await _companyRepo.GetAsync(id);

            if (company == null)
            {
                return(NotFound(Resources.Companies.CompanyResource.CompanyNotFound));
            }

            if (await _companyRepo.IsExistNameAsync(company.Id, model.Name))
            {
                ModelState.AddModelError("Name", Resources.Global.Common.ThisNameExist);
                return(BadRequest(ModelState.GetWithErrorsKey()));
            }

            company.Name = model.Name;

            var affectedRows = await _companyRepo.EditAsync(company);

            if (affectedRows > 0)
            {
                var viewModel = AutoMapper.Mapper.Map <CompanyViewModel>(company);

                return(Ok(viewModel));
            }
            return(BadRequest());
        }
        // GET: Companies/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var company = await _dataContext.Companies
                          .Include(o => o.User)
                          .Include(ct => ct.CompanyType)
                          .FirstOrDefaultAsync(o => o.Id == id.Value);

            if (company == null)
            {
                return(NotFound());
            }

            var companyType = await _dataContext.CompanyTypes.FirstOrDefaultAsync(o => o.Id == company.CompanyType.Id);

            var view = new EditCompanyViewModel
            {
                GRXX          = company.GRXX,
                GRYY          = company.GRYY,
                Name          = company.Name,
                Address       = company.User.Address,
                Document      = company.User.Document,
                FirstName     = company.User.FirstName,
                Id            = company.Id,
                LastName      = company.User.LastName,
                PhoneNumber   = company.User.PhoneNumber,
                CompanyTypes  = _combosHelper.GetComboCompanyTypes(),
                CompanyTypeId = company.CompanyType.Id
            };

            return(View(view));
        }
        public EditCompanyWindow(Company company)
        {
            InitializeComponent();

            DataContext = new EditCompanyViewModel(this, company);
        }