Ejemplo n.º 1
0
        public ActionResult Index()
        {
            try
            {
                using (ProjeEntities db = new ProjeEntities())
                {
                    var empc = Session["empCompany"] as Company;
                    var emp  = Session["emp"] as Employee;
                    if (emp == null)
                    {
                        Response.Redirect("~/Login/Index");
                    }



                    var cu = db.Companies.Include("UserCompanies").Include("UserCompanies.Userr").Where(z => z.Id == emp.CompanyId).ToList();
                    var ua = db.Userrs.Include("UserAnnouncements").Include("UserAnnouncements.Announcement").ToList();

                    var modelList = new List <AnnouncementsModel>();
                    foreach (var item in ua)
                    {
                        var lua = new List <DetailsAndTitle>();

                        foreach (var item2 in cu)
                        {
                            foreach (var item3 in item2.UserCompanies)
                            {
                                if (item.Id == item3.Userr.Id)
                                {
                                    foreach (var item4 in item.UserAnnouncements)
                                    {
                                        var dat = new DetailsAndTitle();
                                        dat.Details = item4.Details;
                                        dat.Title   = item4.Title;
                                        dat.Id      = item4.Id;
                                        lua.Add(dat);
                                    }
                                    AnnouncementsModel a = new AnnouncementsModel()
                                    {
                                        UserName = new Userr()
                                        {
                                            Id   = item.Id,
                                            Name = item.Name
                                        },
                                        DetailsAndTitle = lua
                                    };
                                    modelList.Add(a);
                                }
                            }
                        }
                    }
                    return(View(emp));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        // ctor
        public AddAnnouncementsViewModel()
        {
            // Property
            Announcement    = new AnnouncementsModel();
            ValidationRules = new AnnouncementsValidator();

            // Command
            PostCommand = new Command(Post);
        }
Ejemplo n.º 3
0
        // ctor
        public AnnouncementsViewModel()
        {
            // Property
            Announcements       = new ObservableCollection <AnnouncementsModel>();
            SelectAnnouncements = new AnnouncementsModel();

            // Get
            Get();


            // Command
            SaveAsPDFCommand       = new Command(SaveAsPDF);
            PullRefreshCommand     = new Command(Refresh);
            GoToPostPageCommand    = new Command(GoToPostPage);
            GoToDetailsPageCommand = new Command(GoToDetailsPage);
        }
Ejemplo n.º 4
0
        // GET: Announcement
        public ActionResult Index()
        {
            try
            {
                using (ProjeEntities db = new ProjeEntities())
                {
                    var usc = Session["UserCompany"] as UserCompany;


                    var aaa = db.Companies.Include("UserCompanies").Include("UserCompanies.Userr").Where(z => z.Id == usc.Company.Id).ToList();
                    var bbb = db.Userrs.Include("UserAnnouncements").Include("UserAnnouncements.Announcement").ToList();
                    var LAnnouncementType = db.Companies.Include("CompanyAnnouncements").Include("CompanyAnnouncements.Announcement").Where(X => X.Id == usc.CompanyId).ToList();

                    ViewBag.La = LAnnouncementType;

                    //foreach (var item in LAnnouncementType)
                    //{
                    //    foreach (var item2 in item.CompanyAnnouncements)
                    //    {
                    //        item2.Announcement.Name
                    //    }
                    //}

                    var modelList = new List <AnnouncementsModel>();
                    foreach (var item in bbb)
                    {
                        var lua = new List <DetailsAndTitle>();

                        foreach (var item2 in aaa)
                        {
                            foreach (var item3 in item2.UserCompanies)
                            {
                                if (item.Id == item3.Userr.Id)
                                {
                                    foreach (var item4 in item.UserAnnouncements)
                                    {
                                        var dat = new DetailsAndTitle();
                                        dat.Details = item4.Details;
                                        dat.Title   = item4.Title;
                                        dat.Id      = item4.Id;
                                        lua.Add(dat);
                                    }
                                    AnnouncementsModel a = new AnnouncementsModel()
                                    {
                                        UserName = new Userr()
                                        {
                                            Id   = item.Id,
                                            Name = item.Name
                                        },
                                        DetailsAndTitle = lua
                                    };
                                    modelList.Add(a);
                                }
                            }
                        }
                    }
                    ViewBag.comb = modelList;

                    //foreach (var item in modelList)
                    //{
                    //    foreach (var item2 in item.DetailsAndTitle)
                    //    {

                    //    }
                    //}


                    return(View());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }