public Error InsertOrUpdateCustomerConflict(CustomerConflictModel conflict, UserModel user, string lockGuid)
        {
            var error = validateConflictModel(conflict);

            if (!error.IsError)
            {
                // Check that the lock is still current
                if (!db.IsLockStillValid(typeof(CustomerConflictSensitivity).ToString(), conflict.Id, lockGuid))
                {
                    error.SetError(EvolutionResources.errRecordChangedByAnotherUser, "ConflictFirstname");
                }
                else
                {
                    CustomerConflictSensitivity temp = null;
                    if (conflict.Id != 0)
                    {
                        temp = db.FindCustomerConflict(conflict.Id);
                    }
                    if (temp == null)
                    {
                        temp = new CustomerConflictSensitivity();
                    }

                    MapToEntity(conflict, temp);

                    db.InsertOrUpdateCustomerConflict(temp);
                    conflict.Id = temp.Id;
                }
            }
            return(error);
        }
        CustomerConflictModel createCustomerConflict(int companyId, int customerId, UserModel user, int conflictWithId)
        {
            CustomerConflictModel model = new CustomerConflictModel {
                CompanyId       = companyId,
                CustomerId      = customerId,
                SensitiveWithId = conflictWithId
            };
            var error = CustomerService.InsertOrUpdateCustomerConflict(model, user, "");

            Assert.IsFalse(error.IsError, error.Message);

            return(model);
        }
        public ActionResult Save(EditCustomerConflictViewModel model, string command)
        {
            if (command.ToLower() == "addselected")
            {
                if (!string.IsNullOrEmpty(model.SelectedItems))
                {
                    string[] items = model.SelectedItems.Split(',');
                    foreach (var item in items)
                    {
                        CustomerConflictModel temp = new CustomerConflictModel {
                            CompanyId       = model.CustomerConflict.CompanyId,
                            CustomerId      = model.CustomerConflict.CustomerId,
                            SensitiveWithId = item.ParseInt()
                        };

                        CustomerService.InsertOrUpdateCustomerConflict(temp, CurrentUser, model.LGS);
                    }
                }
            }
            return(RedirectToAction("CustomerConflicts", new { id = model.ParentId }));
        }
        public CustomerConflictModel FindCustomerConflictModel(int id, CompanyModel company, int customerId, bool bCreateEmptyIfNotfound = true)
        {
            CustomerConflictModel model = null;

            var a = db.FindCustomerConflict(id);

            if (a == null)
            {
                if (bCreateEmptyIfNotfound)
                {
                    model = new CustomerConflictModel {
                        CompanyId = company.Id, CustomerId = customerId
                    }
                }
                ;
            }
            else
            {
                model = MapToModel(a);
            }

            return(model);
        }
        private Error validateConflictModel(CustomerConflictModel model)
        {
            var error = new Error();

            /*
             * string firstName = getFieldValue(model.ConflictFirstname),
             *      surname = getFieldValue(model.ConflictSurname),
             *      email = getFieldValue(model.ConflictEmail);
             *
             * if (string.IsNullOrEmpty(firstName)) {
             *  error.SetError(EvolutionResources.errFirstNameRequired, "ConflictFirstname");
             *
             * } else if (string.IsNullOrEmpty(surname)) {
             *  error.SetError(EvolutionResources.errSurnameRequired, "ConflictSurname");
             *
             * } else if (!string.IsNullOrEmpty(email)) {
             *  // If email address is entered, make sure it is valid
             *  if (!email.IsValidEMail()) {
             *      error.SetError(EvolutionResources.errInvalidEMailAddress, "ConflictEmail");
             *  }
             * }
             */
            return(error);
        }
 public void MapToEntity(CustomerConflictModel model, CustomerConflictSensitivity entity)
 {
     Mapper.Map <CustomerConflictModel, CustomerConflictSensitivity>(model, entity);
 }
 public string LockCustomerConflict(CustomerConflictModel model)
 {
     return(db.LockRecord(typeof(CustomerConflictSensitivity).ToString(), model.Id));
 }