コード例 #1
0
        public Error InsertOrUpdateCustomerFreight(CustomerFreightModel freight, UserModel user, string lockGuid)
        {
            var error = validateCustomerFreightModel(freight);

            if (!error.IsError)
            {
                // Check that the lock is still current
                if (!db.IsLockStillValid(typeof(Customer).ToString(), freight.CustomerId, lockGuid))
                {
                    error.SetError(EvolutionResources.errRecordChangedByAnotherUser, "ContactFirstname");
                }
                else
                {
                    Customer temp = null;
                    if (freight.CustomerId != 0)
                    {
                        temp = db.FindCustomer(freight.CustomerId);
                        if (temp != null)
                        {
                            MapToEntity(freight, temp);

                            db.InsertOrUpdateCustomer(temp);
                        }
                    }
                }
            }
            return(error);
        }
コード例 #2
0
        public CustomerFreightModel FindCustomerFreightModel(int customerId, CompanyModel company)
        {
            CustomerFreightModel model = new CustomerFreightModel {
                CompanyId = company.Id, CustomerId = customerId
            };

            var c = db.FindCustomer(customerId);

            if (c != null)
            {
                model            = MapToCustomerFreightModel(c);
                model.CustomerId = c.Id;
            }

            return(model);
        }
コード例 #3
0
        private Error validateCustomerFreightModel(CustomerFreightModel model)
        {
            var error = isValidNonRequiredString(getFieldValue(model.DeliveryInstructions), 255, "DeliveryInstructions", EvolutionResources.errTextDataRequiredInField);

            if (!error.IsError)
            {
                error = isValidNonRequiredString(getFieldValue(model.DeliveryContact), 30, "DeliveryInstructions", EvolutionResources.errTextDataRequiredInField);
            }
            if (!error.IsError)
            {
                error = isValidNonRequiredString(getFieldValue(model.ShipMethodAccount), 20, "ShipMethodAccount", EvolutionResources.errTextDataRequiredInField);
            }
            if (!error.IsError)
            {
                error = isValidNonRequiredString(getFieldValue(model.WarehouseInstructions), 100, "WarehouseInstructions", EvolutionResources.errTextDataRequiredInField);
            }

            return(error);
        }
コード例 #4
0
 public string LockCustomerFreight(CustomerFreightModel model)
 {
     return(db.LockRecord(typeof(Customer).ToString(), model.CustomerId));
 }
コード例 #5
0
 public void MapToEntity(CustomerFreightModel model, Customer entity)
 {
     Mapper.Map <CustomerFreightModel, Customer>(model, entity);
 }