Exemple #1
0
        public async Task <List <PM_ComponentCustomView> > GetComponentsByUserId_ProjectId(string userid, string projectid, int status = 0)
        {
            var objProject = await _PM_ProjectRepsotitory.GetOneById(projectid);

            var dataWork = await GetAllUnfinishedWorkByUserId(userid, projectid);

            var ids = dataWork.Select(n => n.ComponentId).ToList();

            var time = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");

            var count = 0;

            var query = new StringBuilder();

            query.AppendLine("{");

            query.AppendLine("'Status': {'$eq': " + status + "}");

            query.AppendLine("'DateStart': {'$lt': ISODate('" + time + "T00:00:00.000+07:00')}");

            query.AppendLine(", '_id': { '$in': [");

            foreach (var item in ids)
            {
                count++;
                query.AppendLine(string.Format("'{0}'{1}", item, count == ids.Count ? "" : ","));
            }

            query.AppendLine("]}");

            query.AppendLine("}");

            var data = await _PM_ComponentRepository.GetManyToList(MongoHelper.ConvertQueryStringToDocument(query.ToString()));

            var cus = new List <PM_ComponentCustomView>();

            foreach (var item in data)
            {
                cus.Add(new PM_ComponentCustomView()
                {
                    id          = item.Id,
                    code        = item.Code,
                    title       = item.Title,
                    description = item.Description,
                    dateStart   = item.DateStart.ToString("dd/MM/yyyy HH:mm"),
                    dateEnd     = item.DateEnd.ToString("dd/MM/yyyy HH:mm")
                });
            }

            return(cus);
        }
Exemple #2
0
        public async Task <List <PM_Component> > GetAllByIds(List <string> ids, int status = 0)
        {
            var count = 0;

            var query = new StringBuilder();

            query.AppendLine("{");

            query.AppendLine("'Status': {'$eq': " + status + "}");

            query.AppendLine(", '_id': { '$in': [");

            foreach (var item in ids)
            {
                count++;
                query.AppendLine(string.Format("'{0}'{1}", item, count == ids.Count ? "" : ","));
            }

            query.AppendLine("]}");

            query.AppendLine("}");

            return(await _PM_ComponentRepository.GetManyToList(MongoHelper.ConvertQueryStringToDocument(query.ToString())));
        }