示例#1
0
        public ActionResult Source_edit(long id, ETSource updateSource)
        {
            TempData["messagealert"] = string.Empty;

            if (ModelState.IsValid)
            {
                Sourcee = new ETSource();
                Sourcee = repSource.GetSource(id);

                if (repSource.SourceIsExist(updateSource.SourceName, id))
                {
                    ViewBag.messagealert = "Source already exist";
                    ViewBag.SourceTypes  = repSource.getDataValues("SourceType", Session["UserLevel"].ToString(), Convert.ToInt64(Session["UserID"]), Convert.ToInt64(Session["ReportingUser"]));
                    return(View(Sourcee));
                }
                else
                {
                    Sourcee.SourceName              = updateSource.SourceName;
                    Sourcee.SourceType              = updateSource.SourceType;
                    Sourcee.IsActive                = updateSource.IsActive;
                    Sourcee.ModifiedBy              = Convert.ToInt64(Session["UserID"]);
                    Sourcee.ModifiedDate            = DateTime.Now;
                    dbEntities.Entry(Sourcee).State = EntityState.Modified;
                    dbEntities.SaveChanges();
                    if (Sourcee.SourceID != 0)
                    {
                        TempData["messagealert"] = Status.Update;
                    }
                }
                return(RedirectToAction("Index", "Sources"));
            }
            return(View());
        }
示例#2
0
        public ActionResult Source_add(ETSource Source)
        {
            TempData["messagealert"] = string.Empty;
            ViewBag.messagealert     = string.Empty;

            if (ModelState.IsValid)
            {
                if (Source != null)
                {
                    if (repSource.SourceIsExist(Source.SourceName, 0))
                    {
                        ViewBag.messagealert = "Source already exist";
                        ViewBag.SourceTypes  = repSource.getDataValues("SourceType", Session["UserLevel"].ToString(), Convert.ToInt64(Session["UserID"]), Convert.ToInt64(Session["ReportingUser"]));
                        return(View(Source));
                    }
                    else
                    {
                        Source.UserID       = Convert.ToInt64(Session["UserID"]);
                        Source.CreatedBy    = Convert.ToInt64(Session["UserID"]);
                        Source.CreatedDate  = DateTime.Now;
                        Source.ModifiedBy   = Convert.ToInt64(Session["UserID"]);
                        Source.ModifiedDate = DateTime.Now;
                        dbEntities.ETSources.Add(Source);
                        dbEntities.SaveChanges();
                        if (Source.SourceID != 0)
                        {
                            TempData["messagealert"] = Status.Save;
                        }
                    }
                }
                return(RedirectToAction("Index", "Sources"));
            }
            return(View());
        }
示例#3
0
        public bool SourceUpdateStatus(bool status, long Sourceid)
        {
            Sourcee = new ETSource();
            Sourcee = repSource.GetSource(Sourceid);

            if (Sourcee != null)
            {
                if (status)
                {
                    Sourcee.IsActive     = false;
                    Sourcee.ModifiedBy   = Convert.ToInt64(Session["UserID"]);
                    Sourcee.ModifiedDate = DateTime.Now;
                }
                else
                {
                    Sourcee.ModifiedBy   = Convert.ToInt64(Session["UserID"]);
                    Sourcee.ModifiedDate = DateTime.Now;
                    Sourcee.IsActive     = true;
                }
                dbEntities.Entry(Sourcee).State = EntityState.Modified;
                dbEntities.SaveChanges();
                return(true);
            }

            return(false);
        }
示例#4
0
        public bool SourceDelete(long id)
        {
            if (!dbEntities.ETUsers.Where(x => x.UserID == 1).Any()) // Need to change
            {
                TempData["messagealert"] = Status.Delete;
                Sourcee = new ETSource();
                Sourcee = dbEntities.ETSources.Where(x => x.SourceID == id).SingleOrDefault();
                if (Sourcee != null)
                {
                    dbEntities.ETSources.Remove(Sourcee);
                    dbEntities.SaveChanges();
                    return(true);
                }
            }
            return(false);

            //if (!dbEntities.TBL_ADMIN_USER.Where(x => x.ROLE_ID == id).Any())
            //{
            //    TempData["messagealert"] = Status.Delete;
            //    role = new TBL_ROLE();
            //    role = dbEntities.TBL_ROLE.Where(x => x.ROLE_ID == id && x.ROLE_NAME != "superadmin").SingleOrDefault();
            //    if (role != null)
            //    {
            //        dbEntities.TBL_ROLE.Remove(role);
            //        dbEntities.SaveChanges();
            //        return true;
            //    }
            //}
            //return false;
        }
        public ActionResult Category_view(long Id)
        {
            Category = repCategory.GetCategory(Id);
            ETSource SourceNames = dbEntities.ETSources.Where(x => x.SourceID == Category.SourceID).Single();

            Category.SourceName = SourceNames.SourceName;
            return(View(Category));
        }
示例#6
0
 public ActionResult Source_edit(long Id)
 {
     ViewBag.messagealert = string.Empty;
     Sourcee             = new ETSource();
     Sourcee             = repSource.GetSource(Id);
     ViewBag.SourceTypes = repSource.getDataValues("SourceType", Session["UserLevel"].ToString(), Convert.ToInt64(Session["UserID"]), Convert.ToInt64(Session["ReportingUser"]));
     return(View(Sourcee));
 }
        // GET: Category
        #region Category List
        public ActionResult Index()
        {
            ViewBag.UserPermission = Session["UserLevel"].ToString().ToUpper();
            ViewBag.messagealert   = string.Empty;
            string messagealert = Convert.ToString(TempData["messagealert"]);

            if (!string.IsNullOrEmpty(messagealert))
            {
                ViewBag.messagealert = messagealert;
            }
            Categories = new List <ETCategory>();
            Categories = repCategory.GetAllCategory(Convert.ToInt64(Session["UserID"]), Session["UserLevel"].ToString());
            foreach (var item in Categories)
            {
                //item.SourceName = dbEntities.ETSources.Where(x => x.SourceID == item.SourceID).Select(m => m.SourceName).ToString();
                ETSource SourceNames = dbEntities.ETSources.Where(x => x.SourceID == item.SourceID).Single();
                item.SourceName = SourceNames.SourceName;
            }
            return(View(Categories));
        }
示例#8
0
 public ActionResult Source_view(long Id)
 {
     Sourcee = repSource.GetSource(Id);
     return(View(Sourcee));
 }