예제 #1
0
        public async Task <IActionResult> Update([FromBody] GrpDocumentViewModel value)
        {
            if (ModelState.IsValid)
            {
                //
                var userId = Utilities.GetUserId(this.User);
                //
                var grp = new GroupDocument
                {
                    GroupDocumentId   = Guid.NewGuid(),
                    GroupDocumentCode = value.Code,
                    GroupDocumentName = value.Name,
                    Note            = value.Note,
                    IsPrintTemplate = value.IsPrintTemplate,
                    CreatedBy       = userId,
                    UpdatedBy       = userId,
                    CreatedDate     = DateTime.Now,
                    UpdatedDate     = DateTime.Now,
                };

                //commit
                var ret = await this._unitOfWork.GroupDocuments.Save(grp, value.ID);

                //return client side
                return(Ok(ret));
            }

            return(BadRequest(ModelState));
        }
예제 #2
0
        public async Task <GrpDocumentViewModel> Get(Guid index)
        {
            var c = await this._unitOfWork.GroupDocuments.FindById(index);

            var branch = new GrpDocumentViewModel
            {
                ID   = c.GroupDocumentId,
                Code = c.GroupDocumentCode,
                Name = c.GroupDocumentName,
                Note = c.Note
            };

            return(branch);
        }