public async Task <int> CreateCheckListItem([FromBody] CheckItemViewModel model)
        {
            var ch     = _mapper.Map <CheckItem>(model);
            var userId = _claimPrincipalService.GetClaimFromHttp();
            var user   = await _userService.GetUserByClaimAsync(userId);

            var checkitem = new CheckItem {
                Body = ch.Body, Checked = ch.Checked, CheckListPostId = ch.CheckListPostId
            };
            int id = _checkItemService.InsertCheckItem(checkitem);

            return(id);
        }
        public async Task <IActionResult> UpdateCheckItem([FromBody] CheckItemViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var ch = _mapper.Map <CheckItem>(model);

            var checkpost = new CheckItem {
                Checked = ch.Checked, Body = ch.Body, Id = ch.Id, CheckListPostId = ch.CheckListPostId
            };

            _checkItemService.UpdateCheckItem(checkpost);
            return(new OkObjectResult("Item updated"));
        }
        public TaskViewModel(TaskClass taskClass)
        {
            this.TaskInfo                      = new TaskInformation();
            this.TaskInfo.Barcode              = taskClass.taskInformation.barcode;
            this.TaskInfo.Contractor           = taskClass.taskInformation.contractor;
            this.TaskInfo.IsMoving2012Standard = taskClass.taskInformation.isMoving2012Standard;
            this.TaskInfo.LastServicedBy       = taskClass.taskInformation.lastServicedBy;
            this.TaskInfo.Location             = taskClass.taskInformation.location;
            this.TaskInfo.MaintainedStandard   = taskClass.taskInformation.maintainedStandard;
            this.TaskInfo.OPNumber             = taskClass.taskInformation.opNumber;
            this.TaskInfo.TaskTypeDescription  = taskClass.taskInformation.taskTypeDescription;

            this.LastService             = taskClass.lastService;
            this.LastResult              = taskClass.lastResult;
            this.ThisResult              = taskClass.thisResult;
            this.TaskType                = taskClass.taskType;
            this.ServiceVisitItemNumber  = taskClass.serviceVisitItemNumber;
            this.TaskName                = taskClass.taskName;
            this.SiteEquipmentLineNumber = taskClass.siteEquipmentLineNumber;
            this.ServiceVisitId          = taskClass.serviceVisitID;
            this.SiteId = taskClass.siteID;

            this.Checklists = new List <CheckItemViewModel>();
            if (taskClass.checkLists != null)
            {
                for (int i = 1; i <= taskClass.checkLists.Count; i++)
                {
                    var task = new CheckItemViewModel(taskClass.checkLists[i - 1]);
                    task.StepNumber = i;
                    this.Checklists.Add(task);
                }
            }

            this.Comments = new List <CommentViewModel>();
            if (taskClass.defectReport != null)
            {
                foreach (DefectReport defect in taskClass.defectReport)
                {
                    this.Comments.Add(new CommentViewModel(defect));
                }
            }
        }
 public CheckItem(CheckItemViewModel checkItem)
 {
     Id          = checkItem.Id;
     Description = checkItem.Description;
     if (checkItem.CommentExist)
     {
         Comment  = checkItem.Comment.Description;
         PhotoURL = checkItem.Comment.ImageUrl;
     }
     SiteEquipmentLineNumber = checkItem.SiteEquipmentLineNumber;
     Status         = checkItem.Status;
     UnitEntryValue = new List <UnitEntryValue>();
     if (checkItem.Fields != null)
     {
         foreach (CheckItemFieldViewModel field in checkItem.Fields)
         {
             UnitEntryValue.Add(new UnitEntryValue(field));
         }
     }
 }