Beispiel #1
0
        public async Task <MessageReport> Update(PM_Work model)
        {
            var query = new StringBuilder();

            query.AppendLine("{");
            query.AppendLine("'_id': { '$eq': '" + model.Id + "' }");
            query.AppendLine("}");

            return(await _PM_WorkRepository.Update(MongoHelper.ConvertQueryStringToDocument(query.ToString()), model));
        }
Beispiel #2
0
        public async Task <IActionResult> WorkSubmit(PM_WorkAjax model)
        {
            var result = new MessageReport(false, "Có lỗi xảy ra");

            try
            {
                //Kiểm tra có chọn người tham gia
                if (model.UserIds == "null" || string.IsNullOrWhiteSpace(model.UserIds))
                {
                    result = new MessageReport(false, "Vui lòng người tham gia");
                    return(Json(result));
                }

                //Xóa mapping
                await _PM_WorkService.DeleteByComponentId(model.ComponentId);

                //Lấy component
                var objComponent = await _PM_ComponentService.GetById(model.ComponentId);

                //Split userid
                var ids = model.UserIds.Split(',', StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in ids)
                {
                    var k = new PM_Work()
                    {
                        ComponentId   = model.ComponentId,
                        DateCompleted = DateTime.Now,
                        DateCreated   = DateTime.Now,
                        DateRealStart = objComponent != null ? objComponent.DateStart : DateTime.Now,
                        Id            = ObjectId.GenerateNewId().ToString(),
                        IsCompleted   = false,
                        IsOnScheduled = false,
                        ProjectId     = model.ProjectId,
                        UserId        = item
                    };

                    result = await _PM_WorkService.Create(k);
                }
            }
            catch (Exception ex)
            {
                result = new MessageReport(false, ex.Message);
            }

            return(Json(result));
        }
Beispiel #3
0
 public async Task <MessageReport> Create(PM_Work model)
 {
     return(await _PM_WorkRepository.Add(model));
 }