Example #1
0
 private CustomerDepartment ApplyChanges(CustomerDepartmentEditModel model)
 {
     return(new CustomerDepartment()
     {
         CustomerDepartmentID = model.CustomerDepartmentID,
         Commission = model.Commission,
         Handling = model.Handling,
         CustomerDepartmentName = model.CustomerDepartmentName,
         CustomerID = model.CustomerID,
         CustomerTypeID = model.CustomerTypeID,
         RebateType = model.RebateType,
         RebateRate = model.RebateRate,
         FactorRef = model.FactorRef,
         TransactionTaxReference = model.TransactionTaxReference,
         CreditTerms = model.CreditTerms,
         CreditLimit = model.CreditLimit,
         EmailAddress = model.EmailAddress,
         NoteID = model.NoteID,
         CreatedDate = !string.IsNullOrEmpty(model.CreatedDate) ? DateTime.Parse(model.CreatedDate) : DateTime.Now,
         CreatedBy = _principal.Id,
         UpdatedDate = DateTime.Now,
         UpdatedBy = _principal.Id,
         IsActive = true,
     });
 }
Example #2
0
 public CustomerDepartmentEditModel CreateCustomerDepartment(CustomerDepartmentEditModel model, List <Guid> locaGuidList)
 {
     try
     {
         var item = ApplyChanges(model);
         item.NoteID = SaveNote(model);
         if (model.CustomerDepartmentID == Guid.Empty &&
             model.ItemAdding && !model.ItemDeleting)
         {
             model.CustomerDepartmentID = PrimeActs.Service.IDGenerator.NewGuid(_serverCode[0]);
             item.CustomerDepartmentID  = model.CustomerDepartmentID;
             item.ObjectState           = ObjectState.Added;
             _customerDepartmentService.Insert(item);
             InsertCustomerDepartmentLocation(item, locaGuidList);
         }
         else if (!model.ItemAdding && !model.ItemDeleting)
         {
             item.ObjectState = ObjectState.Modified;
             _customerDepartmentService.Update(item);
             //UpdateCustomerDepartmentLocation(item, locaGuidList); //nem
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Creating Customer Department failed", ex);
     }
     return(model);
 }
Example #3
0
        private CustomerDepartmentEditModel BuildCustomerDepartmentEditModelAC(CustomerDepartment cdentity)
        {
            CustomerDepartmentEditModel strCustDeptList = new CustomerDepartmentEditModel();

            strCustDeptList.CustomerDepartmentName = cdentity.Customer.CustomerCompanyName + " - ";
            strCustDeptList.CustomerDepartmentName = strCustDeptList.CustomerDepartmentName + cdentity.CustomerDepartmentName;
            strCustDeptList.CustomerDepartmentID   = cdentity.CustomerDepartmentID;
            strCustDeptList.CustomerCompanyName    = cdentity.Customer.CustomerCompanyName;
            return(strCustDeptList);
        }
Example #4
0
        private Guid UpdateNote(CustomerDepartmentEditModel model, ApplicationUser author)
        {
            var note = _noteService.Find(model.NoteID.Value);

            note.NoteText        = model.Notes;
            note.NoteDescription = model.NoteDescription;
            note.ObjectState     = ObjectState.Modified;
            _noteService.Update(note);
            return(note.NoteID);
        }
Example #5
0
        private Guid CreateNote(CustomerDepartmentEditModel model, ApplicationUser author)
        {
            var note = new Note
            {
                NoteID          = PrimeActs.Service.IDGenerator.NewGuid(_serverCode[0]),
                NoteText        = model.Notes,
                NoteDescription = model.NoteDescription,
                // IsActive = true,
                ObjectState = ObjectState.Added
            };

            _noteService.Insert(note);
            return(note.NoteID);
        }
Example #6
0
        public List <CustomerDepartmentEditModel> BuildCustomerDepartmentModels(List <CustomerDepartment> customerDepartments)
        {
            var list = new List <CustomerDepartmentEditModel>();

            foreach (var item in customerDepartments)
            {
                var model = new CustomerDepartmentEditModel();
                model.CustomerDepartmentID   = item.CustomerDepartmentID;
                model.CustomerDepartmentName = item.CustomerDepartmentName;
                model.CustomerID             = item.CustomerID;
                model.EmailAddress           = item.EmailAddress;
                model.Commission             = item.Commission.HasValue ? item.Commission.Value : 0;
                model.Handling   = item.Handling.HasValue ? item.Handling.Value : 0;
                model.RebateType = item.RebateType;
                model.RebateRate = item.RebateRate.HasValue ? item.RebateRate.Value : 0;
                model.RebateCustomerDepartmentID           = item.RebateCustomerDepartmentID; //.HasValue ? item.RebateCustomerDepartmentID.Value : Guid.Empty
                model.RebateCustomerCompany_DepartmentName = item.RebateCustomerDepartmentID.HasValue
                    ? _customerDepartmentService.CustomerDepartmentByCustomerDepartmentId(item.RebateCustomerDepartmentID.Value).CustomerDepartmentName
                    : string.Empty;
                model.SalesPersonUserID = item.SalesPersonUserID;
                //model.SalesPersonName = __get_name__(item.SalesPersonUserID); ////////////////////
                model.InvoiceCustomerLocationID    = item.InvoiceCustomerLocationID;
                model.InvoiceCustomerLocation_Name = _customerDepartmentLocationService
                                                     .GetCustomerDepartmentLocationByLocId(item.InvoiceCustomerLocationID)
                                                     .CustomerLocation.CustomerLocationName;
                model.InvoiceFrequency        = item.InvoiceFrequency.ToString();
                model.TransactionTaxReference = item.TransactionTaxReference;
                model.CreditTerms             = item.CreditTerms.HasValue ? item.CreditTerms.Value : 0;
                model.CreditLimit             = item.CreditLimit.HasValue ? item.CreditLimit.Value : 0;
                model.NoteID = item.NoteID;
                model.Notes  = item.NoteID.HasValue ? _noteService.Find(item.NoteID.Value).NoteText : string.Empty;
                // setup LxbViewModel of ListBox
                var customerDepartmentLocations = _customerDepartmentLocationService.GetCustomerDepartmentLocationListByDepId(item.CustomerDepartmentID);
                model.SelectedLocationIds = new List <string>();
                model.LbxLocationOptions  = new List <LbxViewModel>();
                foreach (var cdl in customerDepartmentLocations)
                {
                    model.SelectedLocationIds.Add(cdl.CustomerLocationID.ToString());
                    var lxbItem = new LbxViewModel();
                    lxbItem.Id    = cdl.CustomerLocationID.ToString();
                    lxbItem.label = _customerLocationService.CustomerLocationById(cdl.CustomerLocationID.Value).CustomerLocationName;
                    lxbItem.value = cdl.CustomerLocationID.ToString();
                    model.LbxLocationOptions.Add(lxbItem);
                }
                list.Add(model);
            }
            return(list);
        }
Example #7
0
        public CustomerDepartmentEditModel GetCustomerDepartmentEditModel(Guid id)
        {
            var entity = _customerDepartmentService.CustomerDepartmentById(id);
            var customerCompanyName = _customerService.CustomerById(entity.CustomerID).CustomerCompanyName;
            var model = new CustomerDepartmentEditModel()
            {
                CustomerDepartmentID       = entity.CustomerDepartmentID,
                CustomerDepartmentName     = entity.CustomerDepartmentName,
                RebateCustomerDepartmentID = entity.RebateCustomerDepartmentID,
                RebateRate = entity.RebateRate,
                RebateType = entity.RebateType,
                RebateCustomerCompany_DepartmentName = customerCompanyName + " - " + entity.CustomerDepartmentName
            };

            return(model);
        }
Example #8
0
 private Guid?SaveNote(CustomerDepartmentEditModel model)
 {
     if (string.IsNullOrEmpty(model.NoteDescription))
     {
         model.NoteDescription = "?!";  // <--- Paul Edwards
     }
     if (!string.IsNullOrEmpty(model.Notes))
     {
         if (model.NoteID == null || model.NoteID == Guid.Empty)
         {
             model.NoteID = CreateNote(model, _principal);
         }
         else
         {
             model.NoteID = UpdateNote(model, _principal);
         }
     }
     return(model.NoteID);
 }