public CreateAttachment convertCustomerObjectToAttachment(CustomObject obj) { CreateAttachment attachmentToReturn = new CreateAttachment(); attachmentToReturn.ModifiedBy = obj.CreatedBy; attachmentToReturn.CreatedBy = obj.CreatedBy; attachmentToReturn.Remarks = obj.Remarks; attachmentToReturn.Type = obj.Type; attachmentToReturn.AttachedPath = obj.AttachedPath; attachmentToReturn.Path = configuration.GetSection("AttachmentPath:Path").Value; if (!string.IsNullOrEmpty(obj.ID)) { attachmentToReturn.ID = Convert.ToInt64(obj.ID); } if (!string.IsNullOrEmpty(obj.ProductAttachmentID)) { attachmentToReturn.ProductAttachmentID = Convert.ToInt64(obj.ProductAttachmentID); } if (!string.IsNullOrEmpty(obj.DocumentID)) { attachmentToReturn.DocumentID = Convert.ToInt64(obj.DocumentID); } if (!string.IsNullOrEmpty(obj.Serial)) { attachmentToReturn.Serial = Convert.ToInt64(obj.Serial); } if (obj.IsReceived == "true") { attachmentToReturn.IsReceived = 1; } if (obj.File != null) { attachmentToReturn.IsReceived = 1; attachmentToReturn.File = obj.File; } if (!string.IsNullOrEmpty(obj.ClaimID)) { attachmentToReturn.ClaimID = Convert.ToInt64(obj.ClaimID); } if (!string.IsNullOrEmpty(obj.RiskID)) { attachmentToReturn.RiskID = Convert.ToInt64(obj.RiskID); } if (!string.IsNullOrEmpty(obj.Level)) { attachmentToReturn.Level = Convert.ToInt64(obj.Level); } attachmentToReturn.ReceivedDate = DateTime.Now; attachmentToReturn.ModificationDate = DateTime.Now; return(attachmentToReturn); }
public IApiResult Create([FromForm] CustomObject obj) { CreateAttachment operation = convertCustomerObjectToAttachment(obj); var result = operation.ExecuteAsync().Result; if (result is ValidationsOutput) { return(new ApiResult <List <ValidationItem> >() { Data = ((ValidationsOutput)result).Errors }); } else { return(new ApiResult <object>() { Status = ApiResult <object> .ApiStatus.Success, ID = ((ComplateOperation <int>)result).ID.Value }); } }