Beispiel #1
0
        public ActionResult EditCategory(string Id)
        {
            CategoryMaster c = new CategoryMaster();

            c = Commonhelper.GetCategoryById(Id);
            return(View(c));
        }
 public JsonResult Create(CategoryMaster cat)
 {
     try
     {
         string        query         = @"insert into CategoryMaster (Category_Name,Category_Description,User_Id,Product_Id) values ('" + cat.CategoryName + "','" + cat.CategoryDescription + "','" + cat.Id + "','" + cat.ProductId + "')";
         DataTable     table         = new DataTable();
         string        sqlDataSource = configuration.GetConnectionString("DataConnection");
         SqlDataReader dataReader;
         using (SqlConnection connection = new SqlConnection(sqlDataSource))
         {
             connection.Open();
             using (SqlCommand command = new SqlCommand(query, connection))
             {
                 dataReader = command.ExecuteReader();
                 table.Load(dataReader);
                 dataReader.Close();
                 connection.Close();
             }
         }
         return(new JsonResult("Data Inserted"));
     }
     catch (Exception e)
     {
         return(new JsonResult(e.Message));
     }
 }
        protected void rpProduct_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            var rpSubProduct = e.Item.FindControl("rpSubProduct") as Repeater;

            if (rpSubProduct != null)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    CategoryMaster cat = e.Item.DataItem as CategoryMaster;
                    if (cat != null)
                    {
                        var subCatList = _subCategorys.Where(x => x.Category_ID == cat.CATEGORY_ID).ToList();
                        if (subCatList == null || subCatList.Count == 0)
                        {
                            rpSubProduct.HeaderTemplate = null;
                            rpSubProduct.FooterTemplate = null;
                        }
                        else
                        {
                            rpSubProduct.DataSource = subCatList;
                            rpSubProduct.DataBind();
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public IHttpActionResult PutCategoryMaster(int id, CategoryMaster categoryMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != categoryMaster.Id)
            {
                return(BadRequest());
            }

            db.Entry(categoryMaster).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoryMasterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public virtual IList <CategoryMaster> GetCategoryBreadCrumb(CategoryMaster category, IList <CategoryMaster> allCategories = null, bool showHidden = false)
        {
            try
            {
                if (category == null)
                {
                    throw new ArgumentNullException(nameof(category));
                }

                List <CategoryMaster> result = new List <CategoryMaster>();

                //used to prevent circular references
                List <int> alreadyProcessedCategoryIds = new List <int>();

                while (category != null &&                                                          //not null
                       category.IsActive &&
                       !alreadyProcessedCategoryIds.Contains(Convert.ToInt32(category.CategoryID))) //prevent circular references
                {
                    result.Add(category);

                    alreadyProcessedCategoryIds.Add(Convert.ToInt32(category.CategoryID));

                    category = allCategories != null?allCategories.FirstOrDefault(c => c.CategoryID == category.ParentCategoryId)
                                   : GetCategoryById(category.ParentCategoryId);
                }

                result.Reverse();
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #6
0
        public DataBaseResultSet SaveCategoryMaster <T>(T objData) where T : class, IModel, new()
        {
            CategoryMaster     obj    = objData as CategoryMaster;
            string             sQuery = "sprocCategoryMasterInsertUpdateSingleItem";
            List <DbParameter> list   = new List <DbParameter>();

            list.Add(SqlConnManager.GetConnParameters("CategoryCode", "CategoryCode", 8, GenericDataType.Long, ParameterDirection.Input, obj.CategoryCode));
            list.Add(SqlConnManager.GetConnParameters("ICode", "ICode", 13, GenericDataType.String, ParameterDirection.Input, obj.ICode));
            list.Add(SqlConnManager.GetConnParameters("CategoryName", "CategoryName", 50, GenericDataType.String, ParameterDirection.Input, obj.CategoryName));
            list.Add(SqlConnManager.GetConnParameters("CUser", "CUser", 8, GenericDataType.Long, ParameterDirection.Input, obj.CUser));
            list.Add(SqlConnManager.GetConnParameters("CDateTime", "CDateTime", 8, GenericDataType.DateTime, ParameterDirection.Input, obj.CDateTime));
            list.Add(SqlConnManager.GetConnParameters("EUser", "EUser", 8, GenericDataType.Long, ParameterDirection.Input, obj.EUser));
            list.Add(SqlConnManager.GetConnParameters("EDateTime", "EDateTime", 8, GenericDataType.DateTime, ParameterDirection.Input, obj.EDateTime));
            list.Add(SqlConnManager.GetConnParameters("LCode", "LCode", 8, GenericDataType.Long, ParameterDirection.Input, obj.LCode));
            list.Add(SqlConnManager.GetConnParameters("DLock", "DLock", 3, GenericDataType.String, ParameterDirection.Input, obj.DLock));
            list.Add(SqlConnManager.GetConnParameters("CreatedBy", "CreatedBy", 50, GenericDataType.String, ParameterDirection.Input, obj.CreatedBy));
            list.Add(SqlConnManager.GetConnParameters("CreatedDate", "CreatedDate", 8, GenericDataType.DateTime, ParameterDirection.Input, obj.CreatedDate));
            list.Add(SqlConnManager.GetConnParameters("UpdateddBy", "UpdateddBy", 50, GenericDataType.String, ParameterDirection.Input, obj.UpdateddBy));
            list.Add(SqlConnManager.GetConnParameters("UpdatedDate", "UpdatedDate", 8, GenericDataType.DateTime, ParameterDirection.Input, obj.UpdatedDate));
            list.Add(SqlConnManager.GetConnParameters("UpdatedCount", "UpdatedCount", 4, GenericDataType.Int, ParameterDirection.Input, obj.UpdatedCount));
            list.Add(SqlConnManager.GetConnParameters("LUT", "LUT", 8, GenericDataType.DateTime, ParameterDirection.Input, obj.LUT));
            list.Add(SqlConnManager.GetConnParameters("OperationFlag", "OperationFlag", 4, GenericDataType.Int, ParameterDirection.Input, (short)obj.OperationFlag));
            list.Add(SqlConnManager.GetConnParameters("Message", "Message", 300, GenericDataType.String, ParameterDirection.Output, null));
            list.Add(SqlConnManager.GetConnParameters("ErrorCode", "ErrorCode", 4, GenericDataType.Int, ParameterDirection.Output, null));
            return(SqlConnManager.Save(sQuery, CommandType.StoredProcedure, list.ToArray()));
        }
        public async Task <IActionResult> PostCategoryMaster([FromBody] CategoryMaster categoryMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.CategoryMaster.Add(categoryMaster);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (CategoryMasterExists(categoryMaster.CategoryId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetCategoryMaster", new { id = categoryMaster.CategoryId }, categoryMaster));
        }
        public async Task <IActionResult> PutCategoryMaster([FromRoute] int id, [FromBody] CategoryMaster categoryMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != categoryMaster.CategoryId)
            {
                return(BadRequest());
            }

            _context.Entry(categoryMaster).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoryMasterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #9
0
        /// <summary>
        /// used to save the category info in the database
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="categoryName"></param>
        /// <param name="isVisible"></param>
        /// <returns></returns>
        public static bool SaveCategoryInfo(int categoryId, string categoryName, bool isVisible)
        {
            try
            {
                using (var nie = new NewsIndiaTVEntities())
                {
                    var categoryMaster = nie.CategoryMasters.FirstOrDefault(m => m.ID == categoryId);

                    if (categoryMaster != null)
                    {
                        categoryMaster.CategoryName = categoryName;
                        categoryMaster.IsVisible    = isVisible;
                    }
                    else
                    {
                        categoryMaster = new CategoryMaster()
                        {
                            CategoryName = categoryName,
                            IsVisible    = isVisible,
                            IsActive     = true
                        };
                        nie.CategoryMasters.Add(categoryMaster);
                    }
                    nie.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 public long InsertUpdateCategoryDetails(CompanyBE.CategoryBE lst)
 {
     if (lst.CategoryId != 0)
     {
         var objCategory = _ObjEINS_RBMSEntities.CategoryMasters.FirstOrDefault(x => x.CategoryId == lst.CategoryId);
         objCategory.CategoryName        = lst.CategoryName;
         objCategory.CategoryDescription = lst.CategoryDescription;
         objCategory.CategoryStatus      = true;
         objCategory.ModifiedBy          = lst.LastModifiedBy;
         objCategory.ModifiedOn          = DateTime.Now;
         _ObjEINS_RBMSEntities.SaveChanges();
         return(objCategory.CategoryId);
     }
     else
     {
         CategoryMaster _Obj = new CategoryMaster();
         _Obj.CategoryName        = lst.CategoryName;
         _Obj.CategoryDescription = lst.CategoryDescription;
         _Obj.CategoryStatus      = true;
         _Obj.AddedBy             = lst.AddedBy;
         _Obj.AddedOn             = DateTime.Now;
         _ObjEINS_RBMSEntities.AddToCategoryMasters(_Obj);
         _ObjEINS_RBMSEntities.SaveChanges();
         return(_Obj.CategoryId);
     }
 }
 protected void btnsubmit_Click(object sender, EventArgs e)
 {
     try
     {
         CategoryMaster cm = new CategoryMaster();
         if (btnsubmit.Text == "Submit")
         {
             cm.CATEGORY_ID   = CategoryMaster.MaxID() + 1;
             cm.CATEGORY_NAME = txtcategory.Text;
             cm.REMARK        = txtremark.Text;
             cm.Save();
             grid();
             ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Submit Successfully....');</Script>", false);
         }
         else if (btnsubmit.Text == "Update")
         {
             cm               = CategoryMaster.GetByCATEGORY_ID(int.Parse(ViewState["id"].ToString()));
             cm.CATEGORY_ID   = int.Parse(ViewState["id"].ToString());
             cm.CATEGORY_NAME = txtcategory.Text;
             cm.REMARK        = txtremark.Text;
             cm.Save();
             grid();
             ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Update Successfully...');</Script>", false);
         }
         ClearInputs(Page.Controls);
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert(error);</script>", false);
     }
 }
        public ActionResult AddCategory(CategoryMaster U)
        {
            if (ModelState.IsValid)
            {
                if (TempData["IsEdit"] != null && TempData["IsEdit"] == "1")
                {
                    U.CategoryID = Convert.ToInt32(TempData["Id"].ToString());
                    repository.Update(U);
                    repository.Save();
                    TempData["Message"] = "Record Update Succesfully";
                    TempData["IsEdit"]  = "0";
                }
                else
                {
                    repository.Insert(U);
                    repository.Save();
                    TempData["Message"] = "Record Save Succesfully";
                    TempData["IsEdit"]  = "0";
                }
            }
            else
            {
                TempData["Message"] = "All fields are required with *";
            }


            ViewBag.userdetails = repository.GetAll();
            return(RedirectToAction("Index"));
        }
Beispiel #13
0
        public ActionResult DeleteConfirmed(int id)
        {
            CategoryMaster categoryMaster = uow.CategoryRepository.GetByID(id);

            uow.CategoryRepository.Delete(categoryMaster);
            uow.Save();
            return(RedirectToAction("Index"));
        }
Beispiel #14
0
        public ActionResult DeleteConfirmed(int id)
        {
            CategoryMaster categoryMaster = db.CategoryMasters.Find(id);

            db.CategoryMasters.Remove(categoryMaster);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #15
0
        public void GetListCategoryMaster <T>(T objFilter, ref List <T> listData) where T : class, IModel, new()
        {
            string             sQuery  = "GetListCategoryMaster";
            CategoryMaster     objData = objFilter as CategoryMaster;
            List <DbParameter> list    = new List <DbParameter>();

            list.Add(SqlConnManager.GetConnParameters("CategoryCode", "CategoryCode", 8, GenericDataType.Long, ParameterDirection.Input, objData.CategoryCode));
            SqlConnManager.GetList <T>(sQuery, CommandType.StoredProcedure, list.ToArray(), FillCategoryMasterDataFromReader, ref listData);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            CategoryMaster categoryMaster = await db.CategoryMasters.FindAsync(id);

            db.CategoryMasters.Remove(categoryMaster);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Beispiel #17
0
 public ActionResult Edit([Bind(Include = "Id,CategoryName,CategoryOverview")] CategoryMaster categoryMaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categoryMaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categoryMaster));
 }
Beispiel #18
0
 public ActionResult Edit([Bind(Include = "ID,Name")] CategoryMaster categoryMaster)
 {
     if (ModelState.IsValid)
     {
         uow.CategoryRepository.Update(categoryMaster);
         uow.Save();
         return(RedirectToAction("Index"));
     }
     return(View(categoryMaster));
 }
Beispiel #19
0
 private void FillCategoryMasterDataFromReader <T>(DbDataReader DbReader, ref List <T> listData) where T : class, IModel, new()
 {
     while (DbReader.Read())
     {
         T obj = new T();
         CategoryMaster objData = obj as CategoryMaster;
         obj.FillDataFromDB(DbReader);
         listData.Add(obj);
     }
 }
Beispiel #20
0
        public ActionResult Create([Bind(Include = "Id,CategoryName,CategoryOverview")] CategoryMaster categoryMaster)
        {
            if (ModelState.IsValid)
            {
                db.CategoryMasters.Add(categoryMaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(categoryMaster));
        }
        public async Task <ActionResult> Edit([Bind(Include = "ID,Name")] CategoryMaster categoryMaster)
        {
            if (ModelState.IsValid)
            {
                db.Entry(categoryMaster).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(categoryMaster));
        }
        public void Update(CategoryMaster categoryMaster)
        {
            var category = testContext.CategoryMaster.Find(categoryMaster.CategoryId);

            category.Cgst = categoryMaster.Cgst;
            category.Igst = categoryMaster.Igst;
            category.Name = categoryMaster.Name;
            category.Sgst = categoryMaster.Sgst;

            testContext.SaveChanges();
        }
Beispiel #23
0
        public IHttpActionResult GetCategoryMaster(int id)
        {
            CategoryMaster categoryMaster = db.CategoryMaster.Find(id);

            if (categoryMaster == null)
            {
                return(NotFound());
            }

            return(Ok(categoryMaster));
        }
        public ActionResult Edit(int id)
        {
            CategoryMaster Editcoat = (from u in repository.GetAll()
                                       where u.CategoryID == id
                                       select u).FirstOrDefault();

            TempData["Id"]      = id;
            ViewBag.userdetails = repository.GetAll();
            TempData["IsEdit"]  = "1";
            return(View("Index", Editcoat));
        }
Beispiel #25
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (Session["admin"] == null)
            {
                return(RedirectToAction("Index", "adminLogin"));
            }
            CategoryMaster categoryMaster = db.CategoryMasters.Find(id);

            db.CategoryMasters.Remove(categoryMaster);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Create([Bind(Include = "ID,Name")] CategoryMaster categoryMaster)
        {
            if (ModelState.IsValid)
            {
                db.CategoryMasters.Add(categoryMaster);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(categoryMaster));
        }
        public async Task <IActionResult> PostCategoryMaster([FromBody] CategoryMaster categoryMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.CategoryMaster.Add(categoryMaster);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCategoryMaster", new { id = categoryMaster.CategoryId }, categoryMaster));
        }
 public void InsertCategory(CategoryMaster category)
 {
     try
     {
         context.Category.Add(category);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #29
0
        public IHttpActionResult PostCategoryMaster(CategoryMaster categoryMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CategoryMaster.Add(categoryMaster);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = categoryMaster.Id }, categoryMaster));
        }
 public void UpdateCategory(CategoryMaster category)
 {
     try
     {
         context.Update(category);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }