Example #1
0
 internal static CustomerModel GetModelFromCustomer(CustomerOrganisation customer, string message = null, bool allowEdit = true)
 {
     return(new CustomerModel
     {
         IsCreating = false,
         CustomerId = customer.CustomerOrganisationId,
         Name = customer.Name,
         ParentName = customer.ParentCustomerOrganisation?.Name,
         ParentId = customer.ParentCustomerOrganisationId,
         PriceListType = customer.PriceListType,
         EmailDomain = customer.EmailDomain,
         OrganisationPrefix = customer.OrganisationPrefix,
         OrganisationNumber = customer.OrganisationNumber,
         PeppolId = customer.PeppolId,
         TravelCostAgreementType = customer.TravelCostAgreementType,
         UseOrderAgreementsFromDate = customer.UseOrderAgreementsFromDate,
         Message = message,
         UserPageMode = new UserPageMode
         {
             BackController = "Customer",
             BackAction = "View",
             BackId = customer.CustomerOrganisationId.ToSwedishString()
         },
         CustomerSettings = customer.CustomerSettings.Select(c => new CustomerSettingModel {
             CustomerSettingType = c.CustomerSettingType, Value = c.Value
         }).OrderBy(csm => csm.CustomerSettingType.GetDescription()).ToList(),
         AllowEdit = allowEdit
     });
 }
Example #2
0
 internal void UpdateCustomer(CustomerOrganisation customer, bool isNewCustomer = false)
 {
     customer.Name = Name;
     customer.ParentCustomerOrganisationId = ParentId;
     customer.EmailDomain                = EmailDomain;
     customer.OrganisationNumber         = OrganisationNumber;
     customer.PeppolId                   = PeppolId;
     customer.UseOrderAgreementsFromDate = ShowUseOrderAgreementsFromDate ? UseOrderAgreementsFromDate : null;
     if (isNewCustomer)
     {
         customer.PriceListType           = PriceListType.Value;
         customer.OrganisationPrefix      = OrganisationPrefix;
         customer.TravelCostAgreementType = TravelCostAgreementType.Value;
         customer.CustomerSettings.AddRange(CustomerSettings.Select(c => new CustomerSetting {
             CustomerSettingType = c.CustomerSettingType, Value = c.Value
         }).ToList());
     }
 }
        public async Task <ActionResult> Create(CustomerModel model)
        {
            if (ModelState.IsValid && ValidateCustomer(model))
            {
                CustomerOrganisation customer = new CustomerOrganisation();
                model.UpdateCustomer(customer, true);
                _dbContext.Add(customer);
                await _cacheService.Flush(CacheKeys.CustomerSettings);

                await _dbContext.SaveChangesAsync();

                customer = await _dbContext.CustomerOrganisations.GetCustomerById(customer.CustomerOrganisationId);

                _notificationService.CustomerCreated(customer);
                return(RedirectToAction(nameof(View), new { Id = customer.CustomerOrganisationId, Message = "Myndighet har skapats" }));
            }
            return(View(model));
        }
Example #4
0
 public void CustomerCreated(CustomerOrganisation customer)
 {
 }