public SubCatogory GetSubAssest(int?SCId)
        {
            PetaPoco.Database db = null;
            var         dbConn   = DataContext.Database.Connection;
            SubCatogory assest   = new SubCatogory();

            try
            {
                using (DataContext)
                {
                    dbConn.Open();
                    db = new PetaPoco.Database(dbConn);
                    db.EnableAutoSelect = false;
                    assest = db.Query <SubCatogory>("exec usp_GetSubAssest " + "@SCId",
                                                    new { SCId = SCId }).FirstOrDefault();
                    dbConn.Close();
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            finally
            {
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return(assest);
        }
        public int AddSubAssest(SubCatogory assest)
        {
            int id = 0;

            PetaPoco.Database db = null;
            var dbConn           = DataContext.Database.Connection;

            try
            {
                dbConn.Open();
                db = new PetaPoco.Database(dbConn);
                db.EnableAutoSelect = false;
                id = db.ExecuteScalar <int>("declare @@ret INT; exec @@ret = usp_AddSubAssest " + " @MCId,@SCName,@SCSymbol; select @@ret;",
                                            new
                {
                    @MCId     = assest.MCId,
                    @SCName   = assest.SCName,
                    @SCSymbol = assest.SCSymbol
                });
            }
            catch (Exception ex)
            {
            }

            finally
            {
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return(id);
        }
Example #3
0
        public ActionResult ReviewSubCatogory(int?SCId)
        {
            UserService service = new UserService();
            SubCatogory assest  = new SubCatogory();

            //ViewBag.Divisions = new SelectList(AllDivisions(), "Value", "Text");

            assest = service.GetSubAssest(SCId);

            return(View("ReviewSubAssest", assest));
        }
Example #4
0
        public int UpdateSubAssest(SubCatogory assest)
        {
            int id = 0;

            try
            {
                id = _repository.UpdateSubAssest(assest);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(id);
        }
Example #5
0
        public ActionResult AddEditSubAssest(int?SCId)
        {
            UserService service = new UserService();
            SubCatogory assest  = new SubCatogory();

            assest = service.GetSubAssest(SCId);
            if (assest == null)
            {
                assest = new SubCatogory();
            }
            ViewBag.MainAssests = new SelectList(AllMainAssests(), "Value", "Text");
            //ViewBag.Designations = new SelectList(AllDesignation(user.Division), "Value", "Text");
            return(View("AddEditSubAssest", assest));
        }
Example #6
0
        public SubCatogory GetSubAssest(int?SCId)
        {
            SubCatogory assest = new SubCatogory();

            try
            {
                assest = _repository.GetSubAssest(SCId);
            }

            catch (Exception ex)
            {
                throw;
            }

            return(assest);
        }
Example #7
0
        public ActionResult SaveSubAssest(SubCatogory assest)
        {
            int         id      = 0;
            UserService service = new UserService();

            try
            {
                if (assest.SCId > 0)
                {
                    id = service.UpdateSubAssest(assest);
                    return(Json(new { Status = true, Id = id, Message = "Record updated successfully" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    id = service.AddSubAssest(assest);
                    return(Json(new { Status = true, Id = id, Message = "Record added successfully" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Status = false, Message = "Error Occured" }, JsonRequestBehavior.AllowGet));
            }
        }