예제 #1
0
        private CompanyModel PrepareCompanyMode( Company company )
        {
            Guard.IsNotNull(company, "company");

            var model = new CompanyModel()
                {
                    RowId = company.RowId,
                    CompanyName = company.CompanyName,
                    Abbreviation = company.Abbreviation,
                    LogoId = fileDataService.GetFileUrl(company.LogoId.Value),
                };

            PrepareAuditHistoryModel(model, company);

            return model;
        }
예제 #2
0
        public ActionResult Create(CompanyModel model)
        {
            if (ModelState.IsValid)
            {
                var company = new Company
                {
                    CompanyName = model.CompanyName,
                    Abbreviation = model.Abbreviation,
                    CreatedOn = DateTime.UtcNow,
                    LogoId = new Guid(model.LogoId),
                    UpdatedOn = DateTime.UtcNow,
                    CurrentPublishingStatus = PublishingStatus.Active // by default the client status is active
                };

                // we need to add this company
                companyService.Insert(company);

                // return notification message
                SuccessNotification(localizationService.GetResource("Company.Added"));
                return RedirectToAction(SystemRouteNames.Index);
            }

            return View(model);
        }
예제 #3
0
        /// <summary>
        /// Insert a client
        /// </summary>
        /// <param name="client">client</param>
        public virtual void Insert(Company company)
        {
            Guard.IsNotNull(company, "company");

            // add audit history
            company.AuditHistory.Add
             (
                userActivityService.InsertActivity( SystemActivityLogTypeNames.Add,
                    company.ToString(), StateKeyManager.COMPANY_ACTIVITY_COMMENT, company.CompanyName)
             );

            this.companyRepository.Insert(company);

            this.cacheManager.RemoveByPattern(COMPANY_PATTERN_KEY);

            //event notification
            this.eventPublisher.EntityInserted(company);
        }