Example #1
0
        public int AddProduct(Models.DomainModels.Product product)
        {
            prodRepository.Add(product);
            prodRepository.SaveChanges();

            if (product.Documents != null && product.Documents.Count > 0)
            {
                documentService.AddDocuments(product.Documents, product.ProductID, DocumentType.Product);
            }

            return(product.ProductID); // If Exception occurs this line will not be executed
        }
Example #2
0
        public bool SaveInquiry(InquiryResponse inquiryResp)
        {
            bool isCreated = true;

            if (inquiryResp.Inquiry.InquiryID > 0)
            {
                inquiryRepository.Update(inquiryResp.Inquiry);
                isCreated = false;
            }
            else
            {
                inquiryRepository.Add(inquiryResp.Inquiry);
            }
            inquiryRepository.SaveChanges();

            SaveInquiryDetails(inquiryResp);
            documentService.AddDocuments(inquiryResp.InquiryDocuments, inquiryResp.Inquiry.InquiryID, DocumentType.Inquiry);

            //Send Notification
            notificationService.AddNotification(new Notification
            {
                CategoryId      = (int)NotificationType.Inquiry,
                ItemId          = inquiryResp.Inquiry.InquiryID,
                ActionPerformed = isCreated?(int)ActionPerformed.Created: (int)ActionPerformed.Updated,
                CreatedBy       = inquiryResp.Inquiry.UpdatedBy,
                CreatedDate     = DateTime.UtcNow,
                Title           = "Inquiry - " + (inquiryResp.Inquiry.CompanyName.Length > 35? inquiryResp.Inquiry.CompanyName.Substring(0, 35) + "..." : inquiryResp.Inquiry.CompanyName)
            });
            return(true);
        }