public ActionResult Create(SpecActionViewModel item)
        {
            try
            {
                bool specificationExist = true;
                string userId = User.Identity.GetUserId();
                if (userId == null)
                {
                    return RedirectToAction("Login", "Account");
                }

                //Check if the "Admin" role exists if not it returns a null value
                var role = db.Roles.SingleOrDefault(m => m.Name == "Admin");

                if (User.IsInRole("Admin"))
                {
                    //Runs a query to determine if the user is actually an "Admin" if not it returns a null value
                    //var userInRole = db.Users.Where(m => m.Roles.Any(r => r.UserId == userId)).FirstOrDefault();
                    //if (userInRole != null)
                    //{
                    if (item == null)
                    {
                        return RedirectToAction("Retrieve", new { message = ManageMessageId.Error });
                    }

                    if (!String.IsNullOrEmpty(item.Description))
                    {
                        item.Description = helper.ConvertToTitleCase(item.Description);
                        var existingSpec = CheckForDuplicates(item.Description);
                        if (existingSpec == null)
                        {
                            specificationExist = false;
                        }
                        else
                        {
                            var specificationId = db.Specifications.Where(s => s.Description == item.Description).FirstOrDefault().SpecificationId;
                            var recordInProducSpec = db.ProductSpecs.Where(p => p.ProductId == item.ProductId && p.SpecificationId == specificationId).FirstOrDefault();

                            if (recordInProducSpec == null)
                            {
                                var newProductSpecRecord = new ProductSpecViewModel()
                                {
                                    ProductId = item.ProductId,
                                    SpecificationId = specificationId
                                };
                                db.ProductSpecs.Add(newProductSpecRecord);
                                db.SaveChanges();
                            }
                            specificationExist = true;
                        }
                    }

                    if (specificationExist == false)
                    {
                        var spec = new SpecificationViewModel()
                        {
                            SpecialCatId = item.SpecialCatId,
                            Status = "Active",
                            Description = item.Description
                        };

                        var productSpec = new ProductSpecViewModel()
                        {
                            ProductId = item.ProductId,
                            SpecificationId = -1
                        };

                        if (ModelState.IsValid)
                        {
                            db.Specifications.Add(spec);
                            db.SaveChanges();
                            productSpec.SpecificationId = spec.SpecificationId;
                            db.ProductSpecs.Add(productSpec);
                            db.SaveChanges();
                            return RedirectToAction("Retrieve", new { message = ManageMessageId.AddSuccess });
                        }
                        ViewBag.TagId = new SelectList(db.SpecialCategories, "SpecialCatId", "Description", spec.SpecialCatId);
                        return View(item);
                    }

                    return RedirectToAction("Retrieve");
                }
                return RedirectToAction("Login", "Account");
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }
        // GET: SupplierSpecification/Create
        public ActionResult Create()
        {
            try
            {
                string userId = User.Identity.GetUserId();
                if (userId == null)
                {
                    return RedirectToAction("Login", "Account");
                }

                if (User.IsInRole("Supplier"))
                {
                    var newItem = new SpecActionViewModel();

                    ViewBag.SpecialCatId = new SelectList(db.SpecialCategories, "SpecialCatId", "Description");
                    ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Description");

                    var records = _repository.Retrieve();
                    ViewData["SpecificationList"] = records;
                    return View(newItem);
                }
                return RedirectToAction("Login", "Account");
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }
        // GET: Specification/Create
        public ActionResult Create()
        {
            try
            {
                string userId = User.Identity.GetUserId();
                if (userId == null)
                {
                    return RedirectToAction("Login", "Account");
                }

                //Check if the "Admin" role exists if not it returns a null value
                var role = db.Roles.SingleOrDefault(m => m.Name == "Admin");

                if (User.IsInRole("Admin"))
                {
                    var newItem = new SpecActionViewModel();

                    ViewBag.SpecialCatId = new SelectList(db.SpecialCategories, "SpecialCatId", "Description");
                    ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Description");

                    var records = _repository.Retrieve();
                    ViewData["SpecificationList"] = records;

                    GetNewSupplierActivation();
                    GetNewModelsActivation();
                    return View(newItem);
                }
                return RedirectToAction("Login", "Account");
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }
        public ActionResult Create(SpecActionViewModel item)
        {
            try
            {
                string userId = User.Identity.GetUserId();
                if (userId == null)
                {
                    return RedirectToAction("Login", "Account");
                }

                if (User.IsInRole("Supplier"))
                {
                    //Runs a query to determine if the user is actually an "Admin" if not it returns a null value
                    //var userInRole = db.Users.Where(m => m.Roles.Any(r => r.UserId == userId)).FirstOrDefault();
                    //if (userInRole != null)
                    //{
                    if (item == null)
                    {
                        return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Item cannot be null!");
                    }

                    //  var newItem = _repository.Create(item);
                    var spec = new SpecificationViewModel()
                    {
                        SpecialCatId = item.SpecialCatId,
                        Status = "Active",
                        Description = item.Description
                    };

                    var productSpec = new ProductSpecViewModel()
                    {
                        ProductId = item.ProductId,
                        SpecificationId = -1
                    };

                    if (ModelState.IsValid)
                    {
                        db.Specifications.Add(spec);
                        db.SaveChanges();
                        productSpec.SpecificationId = spec.SpecificationId;
                        db.ProductSpecs.Add(productSpec);
                        db.SaveChanges();
                        return RedirectToAction("Retrieve");
                    }
                    ViewBag.TagId = new SelectList(db.SpecialCategories, "SpecialCatId", "Description", spec.SpecialCatId);
                    return View(item);
                }
                return RedirectToAction("Login", "Account");
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.ToString());
            }
        }