コード例 #1
0
        public async Task <ExpandoObject> MyWorkTimes()
        {
            dynamic model = new ExpandoObject();

            model.Email = User.Identity.GetUserName();
            Person _suppPerson = await _storePerson.FindByEmailAsync(model.Email);

            IEnumerable <Person> persons = await _storePerson.GetAll();

            List <Entity> entities = new List <Entity>();

            //To restrict information sending to client, send only Id and Name
            persons.ForEach(p => { entities.Add(new Entity()
                {
                    Id = p.Id, Name = p.Name
                }); });
            model.Persons = entities;

            IEnumerable <WorkTime> myWorkTimes = await _storeWorkTime.WorkTimesGetBySupp(_suppPerson.Id);

            myWorkTimes = myWorkTimes.OrderByDescending(x => x.OpDate);
            foreach (var myWorkTime in myWorkTimes)
            {
                myWorkTime.Client    = persons.FirstOrDefault(p => p.Id == myWorkTime.ClientId);
                myWorkTime.Supporter = persons.FirstOrDefault(p => p.Id == myWorkTime.SuppId);
            }

            model.WorkTimes = myWorkTimes;
            model.Status    = HttpStatusCode.OK;

            return(model);
        }
コード例 #2
0
        //[AllowCrossSite]
        public async Task <JsonResult> MyIssuesJson()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Json("Need to login"));
            }
            _suppPerson = await _storePerson.FindByEmailAsync(_email);

            dynamic model = new ExpandoObject();

            model.Email = _email;

            IEnumerable <Person> persons = await _storePerson.GetAll();

            List <Entity> entities = new List <Entity>();

            //To restrict information sending to client, send only Id and Name
            persons.ForEach(p => { entities.Add(new Entity()
                {
                    Id = p.Id, Name = p.Name
                }); });
            model.Persons = entities;

            IEnumerable <Issue> issues = await _storeIssue.GetSuppIssues(_suppPerson.Id);

            issues = issues.OrderByDescending(x => x.OpDate);
            foreach (var issue in issues)
            {
                issue.Client    = persons.FirstOrDefault(p => p.Id == issue.ClientId);
                issue.Supporter = persons.FirstOrDefault(p => p.Id == issue.SuppId);
            }

            model.Issues = issues;

            return(Json(model, JsonRequestBehavior.AllowGet));
        }