Ejemplo n.º 1
0
        public async Task <ResponseMessage> SaveDesign(DesignVm designVm)
        {
            try
            {
                var design = JsonConvert.DeserializeObject <Design>(designVm.SerializedDesign);

                if (design.Id == null)
                {
                    if (string.IsNullOrEmpty(design.ReferenceId))
                    {
                        design.ReferenceId = Guid.NewGuid().ToString();
                    }

                    design.CreatedBy   = LoginUser.Name;
                    design.CreatedDate = DateTime.UtcNow;
                }

                design.UpdatedBy   = LoginUser.Name;
                design.UpdatedDate = DateTime.UtcNow;

                var savedDesign = await _designService.SaveDesign(design);

                SaveDocuments(designVm.DocumentFiles, savedDesign.Id, savedDesign.Documents);

                savedDesign = await _designService.SaveDesign(savedDesign);

                if (savedDesign == null)
                {
                    return new ResponseMessage {
                               Status = "Error", Message = "Error saving design."
                    }
                }
                ;

                return(new ResponseMessage {
                    Status = "Ok", Data = savedDesign
                });
            }
            catch (Exception ex)
            {
                _logger?.LogError(ex, "Error saving design.");
                return(new ResponseMessage {
                    Status = "Error", Message = "Error saving design."
                });
            }
        }
Ejemplo n.º 2
0
        public async Task <ResponseMessage> SaveDesign([FromBody] Design design)
        {
            try
            {
                //string loginUserId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

                //var loginUser = await _userService.GetUserByLoginId(loginUserId);

                if (design.Id == null)
                {
                    if (string.IsNullOrEmpty(design.ReferenceId))
                    {
                        design.ReferenceId = Guid.NewGuid().ToString();
                    }

                    design.CreatedBy   = LoginUser.Name;
                    design.CreatedDate = DateTime.UtcNow;
                }

                design.UpdatedBy   = LoginUser.Name;
                design.UpdatedDate = DateTime.UtcNow;


                var savedDesign = await _designService.SaveDesign(design);

                if (savedDesign == null)
                {
                    return new ResponseMessage {
                               Status = "Error", Message = "Error saving design."
                    }
                }
                ;

                return(new ResponseMessage {
                    Status = "Ok", Data = savedDesign
                });
            }
            catch (Exception ex)
            {
                _logger?.LogError(ex, "Error saving design.");
                return(new ResponseMessage {
                    Status = "Error", Message = "Error saving design."
                });
            }
        }