예제 #1
0
        public IActionResult Create([FromBody] PasswordEntryModel model)
        {
            var user = User.GetUser(_userService);

            if (user != null)
            {
                var cat = _categoryService.GetById(model.CategoryId, user.Id);
                if (cat != null)
                {
                    var passwordEntry = PasswordEntry.CreateNew(model.Username, model.Password, model.Title, model.Description, model.Url, model.ExpirationDate, cat.Id);
                    _passwordEntryService.Save(passwordEntry);
                    return(Ok(ResultMessages.Creation_Success));
                }
                return(BadRequest(ResultMessages.Creation_Failed));
            }
            return(Unauthorized(ResultMessages.User_Authorization_NotOnDb));
        }