Beispiel #1
0
        private void PrepareViewBag(ProductTypeAttribute pt)
        {
            List <SelectListItem> Types = new List <SelectListItem>();

            Types.Add(new SelectListItem {
                Text = "Text", Value = "Text"
            });
            Types.Add(new SelectListItem {
                Text = "Number", Value = "Number"
            });
            Types.Add(new SelectListItem {
                Text = "List", Value = "List"
            });
            Types.Add(new SelectListItem {
                Text = "Date", Value = "Date"
            });
            if (pt == null)
            {
                ViewBag.DataType = new SelectList(Types, "Value", "Text");
            }
            else
            {
                ViewBag.DataType = new SelectList(Types, "Value", "Text", pt.DataType);
            }
        }
    /// <summary>
    /// Submit Button Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        AttributeTypeAdmin _AttributeAdmin = new AttributeTypeAdmin();
        ProductTypeAttribute _typeList = new ProductTypeAttribute();

        //Set Values
        _typeList.ProductTypeId = ItemID;

        if (lstAttributeTypeList.SelectedIndex != -1)
        {
           _typeList.AttributeTypeId = int.Parse(lstAttributeTypeList.SelectedValue);
        }

        bool Check = false;

        Check =  _AttributeAdmin.AddProductTypeAttribute(_typeList);

        if (Check)
        {
            //Redirect to List Page
            Response.Redirect(RedirectLink + ItemID);
        }
        else
        {
            //Display Error Message
            lblError.Text = "An error occurred while updating. Please try again.";
            lblError.Visible = true;
        }
    }
Beispiel #3
0
        // GET: /ProductMaster/Create
        //
        public ActionResult Create()
        {
            PrepareViewBag();
            ProductType pt           = new ProductType();
            var         prodTypeAttr = new ProductTypeAttribute();

            pt.ProductTypeAttributes.Add(prodTypeAttr);
            pt.IsActive = true;
            return(View("Create", pt));
        }
Beispiel #4
0
        // GET: /ProductMaster/Create

        public ActionResult Create(int Id) //Id ==>ProductTypeId
        {
            ProductTypeAttribute TypeAttribute = new ProductTypeAttribute();

            TypeAttribute.ProductType_ProductTypeId = Id;
            TypeAttribute.IsActive = true;
            ViewBag.id             = Id;
            ViewBag.Name           = new ProductTypeService(_unitOfWork).Find(Id).ProductTypeName;
            PrepareViewBag(null);
            return(View(TypeAttribute));
        }
Beispiel #5
0
        // GET: /ProductMaster/Delete/5

        public ActionResult Delete(int id)//->ProductTypeAttributeId
        {
            ProductTypeAttribute TypeAttribute = _ProductTypeAttributeService.Find(id);

            if (TypeAttribute == null)
            {
                return(HttpNotFound());
            }

            ReasonViewModel vm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", vm));
        }
Beispiel #6
0
        public ActionResult EditAttribute(ProductTypeAttribute pta)
        {
            var prodType = _ProductTypeService.Find(pta.ProductType.ProductTypeId);

            pta.ProductType = prodType;

            //if (ModelState.IsValid)
            //{
            pta.ModifiedDate = DateTime.Now;
            pta.ModifiedBy   = User.Identity.Name;
            pta.ObjectState  = Model.ObjectState.Modified;
            new ProductTypeAttributeService(_unitOfWork).Update(pta);
            _unitOfWork.Save();
            return(RedirectToAction("Edit", new { id = pta.ProductType.ProductTypeId }).Success("Data saved successfully"));
            // }
            // return View(pta);
        }
Beispiel #7
0
    protected void uxGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "page")
        {
        }
        else
        {

            //Get the Value from the command argument
            string Id = e.CommandArgument.ToString();

            if (e.CommandName == "Delete")
            {

                AttributeTypeAdmin _Access = new AttributeTypeAdmin();
                ProductTypeAttribute _ProdTypeAttrib = new ProductTypeAttribute();
                _ProdTypeAttrib.ProductAttributeTypeID = int.Parse(Id);

                bool Check = false;
                Check = _Access.DeleteProductTypeAttribute(_ProdTypeAttrib);

            }
        }
    }
Beispiel #8
0
        public ActionResult Post(ProductTypeAttribute pt)
        {
            if (ModelState.IsValid)
            {
                if (pt.ProductTypeAttributeId <= 0)
                {
                    pt.CreatedBy    = User.Identity.Name;
                    pt.CreatedDate  = System.DateTime.Now;
                    pt.ModifiedDate = System.DateTime.Now;
                    pt.ModifiedBy   = User.Identity.Name;
                    _ProductTypeAttributeService.Create(pt);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        ViewBag.id   = pt.ProductType_ProductTypeId;
                        ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductType_ProductTypeId).ProductTypeName;
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductTypeAttribute).DocumentTypeId,
                        DocId        = pt.ProductTypeAttributeId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    return(RedirectToAction("Create", new { id = pt.ProductType_ProductTypeId }).Success("Data saved successfully"));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    ProductTypeAttribute TypeAttribute = _ProductTypeAttributeService.Find(pt.ProductTypeAttributeId);

                    ProductTypeAttribute ExRec = Mapper.Map <ProductTypeAttribute>(TypeAttribute);

                    TypeAttribute.IsActive     = pt.IsActive;
                    TypeAttribute.DefaultValue = pt.DefaultValue;
                    TypeAttribute.Name         = pt.Name;
                    TypeAttribute.IsMandatory  = pt.IsMandatory;
                    TypeAttribute.DataType     = pt.DataType;
                    TypeAttribute.ListItem     = pt.ListItem;
                    TypeAttribute.ModifiedDate = DateTime.Now;
                    TypeAttribute.ModifiedBy   = User.Identity.Name;
                    _ProductTypeAttributeService.Update(TypeAttribute);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = TypeAttribute,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        ViewBag.id   = pt.ProductType_ProductTypeId;
                        ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductType_ProductTypeId).ProductTypeName;
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductTypeAttribute).DocumentTypeId,
                        DocId           = TypeAttribute.ProductTypeAttributeId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(RedirectToAction("Index", new { id = TypeAttribute.ProductType_ProductTypeId }).Success("Data saved successfully"));
                }
            }
            PrepareViewBag(pt);
            return(View(pt));
        }
 public ProductTypeAttribute Create(ProductTypeAttribute p)
 {
     p.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <ProductTypeAttribute>().Insert(p);
     return(p);
 }
 public void Update(ProductTypeAttribute p)
 {
     p.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <ProductTypeAttribute>().Update(p);
 }
 public void Delete(ProductTypeAttribute p)
 {
     _unitOfWork.Repository <ProductTypeAttribute>().Delete(p);
 }