예제 #1
0
        public Error InsertOrUpdateProductCompliance(ProductComplianceModel productCompliance, string lockGuid)
        {
            Error error = ValidateModel(productCompliance);

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

                    Mapper.Map(productCompliance, temp);

                    db.InsertOrUpdateProductCompliance(temp);
                    productCompliance.Id = temp.Id;
                }
            }
            return(error);
        }
예제 #2
0
        private ProductComplianceModel createProductCompliance(CompanyModel testCompany, ProductModel product)
        {
            var cc     = LookupService.FindLOVItemsModel(testCompany, LOVName.ComplianceCategory).FirstOrDefault();
            var market = LookupService.FindLOVItemsModel(testCompany, LOVName.MarketingLocation).FirstOrDefault();

            var model = new ProductComplianceModel();

            model.ProductId              = product.Id;
            model.ComplianceCategoryId   = cc.Id;
            model.ComplianceCategoryText = cc.ItemText;
            model.MarketId       = market.Id;
            model.MarketNameText = market.ItemText;
            return(model);
        }
예제 #3
0
        public ProductComplianceModel FindProductComplianceModel(int id, int productId, bool bCreateEmptyIfNotfound = true)
        {
            ProductComplianceModel model = null;

            var p = db.FindProductCompliance(id);

            if (p == null)
            {
                if (bCreateEmptyIfNotfound)
                {
                    model = new ProductComplianceModel {
                        ProductId = productId
                    }
                }
                ;
            }
            else
            {
                model = MapToModel(p);
            }

            return(model);
        }
예제 #4
0
        public Error ValidateModel(ProductComplianceModel model)
        {
            var error = new Error();

            return(error);
        }
예제 #5
0
 public string LockProductCompliance(ProductComplianceModel model)
 {
     return(db.LockRecord(typeof(ProductCompliance).ToString(), model.Id));
 }
예제 #6
0
 public void AddMediaToProductCompliance(ProductComplianceModel productCompliance, MediaModel media)
 {
     db.AddMediaToProductCompliance(productCompliance.Id, media.Id);
 }