public CustomerContactModel CreateCustomerContact(CustomerContactModel model, List <Guid> locaGuidList, List <Guid> depaGuidList)
 {
     try
     {
         var contItem = ApplyChanges(model);
         if (model.CustomerContactID == Guid.Empty &&
             model.ItemAdding && !model.ItemDeleting)
         {
             model.CustomerContactID    = PrimeActs.Service.IDGenerator.NewGuid(_serverCode[0]);
             contItem.CustomerContactID = model.CustomerContactID;
             contItem.ObjectState       = ObjectState.Added;
             _customerContactService.Insert(contItem);
             InsertCustomerContactLocation(contItem, locaGuidList);
             InsertCustomerContactDepartment(contItem, depaGuidList);
         }
         else if (!model.ItemAdding && !model.ItemDeleting)
         {
             contItem.ObjectState = ObjectState.Modified;
             _customerContactService.Update(contItem);
             //UpdateSupplierContactLocation(contItem, locaGuidList);   /////////////////
             //UpdateSupplierContactDepartment(contItem, depaGuidList); ////////////////
         }
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Creating Customer Contact failed", ex);
     }
     return(model);
 }
Beispiel #2
0
        //[CheckPermission(PageId.Position, Permission.Insert)]
        public async Task <IActionResult> Insert(string customerId, [FromBody] CustomerContactMeta customerContactMeta)
        {
            var result = await _customerContactService.Insert(CurrentUser.TenantId, customerContactMeta);

            //var result = await _CustomerContactService.Insert("1", CustomerContactMeta);
            if (result.Code < 0)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }