public MainCatogory GetMainAssest(int?MCId)
        {
            PetaPoco.Database db = null;
            var          dbConn  = DataContext.Database.Connection;
            MainCatogory assest  = new MainCatogory();

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

            finally
            {
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return(assest);
        }
        public int AddMainAssest(MainCatogory 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_AddMainAssest " + " @MCName,@MCSymbol; select @@ret;",
                                            new
                {
                    @MCName   = assest.MCName,
                    @MCSymbol = assest.MCSymbol
                });
            }
            catch (Exception ex)
            {
            }

            finally
            {
                if (dbConn != null)
                {
                    dbConn.Close();
                }
            }
            return(id);
        }
Exemplo n.º 3
0
        public ActionResult ReviewMainCatogory(int?MCId)
        {
            UserService  service = new UserService();
            MainCatogory assest  = new MainCatogory();

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

            assest = service.GetMainAssest(MCId);

            return(View("ReviewMainAssest", assest));
        }
Exemplo n.º 4
0
        public int UpdateMainAssest(MainCatogory assest)
        {
            int id = 0;

            try
            {
                id = _repository.UpdateMainAssest(assest);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(id);
        }
Exemplo n.º 5
0
        public ActionResult AddEditMainAssest(int?MCId)
        {
            UserService  service = new UserService();
            MainCatogory assest  = new MainCatogory();

            assest = service.GetMainAssest(MCId);
            if (assest == null)
            {
                assest = new MainCatogory();
            }
            //ViewBag.Divisions = new SelectList(AllDivisions(), "Value", "Text");
            //ViewBag.Designations = new SelectList(AllDesignation(user.Division), "Value", "Text");
            return(View("AddEditMainAssest", assest));
        }
Exemplo n.º 6
0
        public MainCatogory GetMainAssest(int?MCId)
        {
            MainCatogory assest = new MainCatogory();

            try
            {
                assest = _repository.GetMainAssest(MCId);
            }

            catch (Exception ex)
            {
                throw;
            }

            return(assest);
        }
Exemplo n.º 7
0
        public ActionResult SaveMainAssest(MainCatogory assest)
        {
            int         id      = 0;
            UserService service = new UserService();

            try
            {
                if (assest.MCId > 0)
                {
                    id = service.UpdateMainAssest(assest);
                    return(Json(new { Status = true, Id = id, Message = "Record updated successfully" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    id = service.AddMainAssest(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));
            }
        }