public BugTrackingResponse <BusinessObjects.Product> Save(BusinessObjects.Product prod)
        {
            Logger.TraceMethodStart(ClassName, "Save");

            var response = new BugTrackingResponse <BusinessObjects.Product>();

            using (var db = new EntityModel.BugTrackingEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var validator = new ProductSpecification();
                        var result    = validator.Validate(prod);
                        var failures  = result.Errors;

                        response.ValidationResult = result;

                        if (result.IsValid)
                        {
                            prod.Active       = true;
                            prod.LastModified = DateTime.Now;
                            var newprod = MapperAllLevels.Map <BusinessObjects.Product, EntityModel.Product>(prod);
                            db.Products.Add(newprod);
                            db.SaveChanges();
                            transaction.Commit();
                        }

                        else
                        {
                            transaction.Rollback();
                            Logger.TraceErrorFormat("Error while Saving {0}", response.ValidationResult.Errors);
                        }

                        return(response);
                    }

                    catch (Exception ex)
                    {
                        Logger.TraceError("Exception: ", ex);
                        transaction.Rollback();
                        throw;
                    }

                    finally
                    {
                        Logger.TraceMethodEnd(ClassName, "Save");
                    }
                }
            }
        }
        public ActionResult CreateProduct([Bind(Include = "ID,Name_Prod,Description_Prod,Active,LastModified")] BusinessObjects.Product prod)
        {
            var response = productmanager.Save(prod);

            if (!response.IsError)
            {
                return(RedirectToAction("/ProductList"));
            }

            else
            {
                foreach (var failer in response.ValidationResult.Errors)
                {
                    ModelState.AddModelError(failer.PropertyName, failer.ErrorMessage);
                }
                return(View());
            }
        }