public async Task <IActionResult> Register([FromBody] UserRegistrationDTO userRegistrationDTO)
        {
            DBStatus status = await authService.RegisterAsync(userRegistrationDTO);

            ResponseStatusDTO responseStatusDTO = new ResponseStatusDTO((int)status, status.ToString());

            if (status == DBStatus.Failed)
            {
                return(BadRequest(new BadResponseDTO {
                    Status = (int)status, Errors = new Errors {
                        Message = new List <string> {
                            status.ToString()
                        }
                    }
                }));
            }
            else if (status == DBStatus.Taken)
            {
                return(BadRequest(new BadResponseDTO {
                    Status = (int)status, Errors = new Errors {
                        Message = new List <string> {
                            "User Id already taken"
                        }
                    }
                }));
            }
            return(Ok(responseStatusDTO));
        }
        public async Task <IActionResult> UpdateStory([FromBody] RequestStoryDTO storyDTO)
        {
            string userId = HttpContext.User.Claims.FirstOrDefault(c => c.Type == System.Security.Claims.ClaimTypes.Sid).Value;

            DBStatus status = await storiesService.ReplaceStoryAsync(storyDTO, userId);

            ResponseStatusDTO responseStatusDTO = new ResponseStatusDTO((int)status, status.ToString());

            if (status == DBStatus.NotFound)
            {
                return(NotFound());
            }
            else if (status == DBStatus.Forbidden)
            {
                return(Forbid());
            }
            else if (status == DBStatus.NotModified)
            {
                return(BadRequest(new BadResponseDTO {
                    Status = (int)status, Errors = new Errors {
                        Message = new List <string> {
                            status.ToString()
                        }
                    }
                }));
            }
            else if (status == DBStatus.PreconditionFailed)
            {
                return(StatusCode(StatusCodes.Status412PreconditionFailed));
            }
            else
            {
                return(Ok(responseStatusDTO));
            }
        }
        public async Task <IActionResult> RemoveStory([Required] Guid storyId)
        {
            string   userId = HttpContext.User.Claims.FirstOrDefault(c => c.Type == System.Security.Claims.ClaimTypes.Sid).Value;
            DBStatus status = await storiesService.RemoveStoryAsync(storyId, userId);

            ResponseStatusDTO responseStatusDTO = new ResponseStatusDTO((int)status, status.ToString());

            if (status == DBStatus.NotFound)
            {
                return(NotFound());
            }
            else if (status == DBStatus.Forbidden)
            {
                return(StatusCode(StatusCodes.Status403Forbidden));
            }
            else if (status == DBStatus.NotDeleted)
            {
                return(BadRequest(new BadResponseDTO {
                    Status = (int)status, Errors = new Errors {
                        Message = new List <string> {
                            status.ToString()
                        }
                    }
                }));
            }
            else
            {
                return(Ok(responseStatusDTO));
            }
        }
        public async Task <IActionResult> UpdateUserPassword([FromBody] UpdateUserPasswordDTO updateUserPasswordDTO)
        {
            string userId = HttpContext.User.Claims.FirstOrDefault(c => c.Type == System.Security.Claims.ClaimTypes.Sid).Value;

            updateUserPasswordDTO.UserId = userId;
            DBStatus status = await userService.UpdateUserPasswordAsync(updateUserPasswordDTO);

            ResponseStatusDTO responseStatusDTO = new ResponseStatusDTO((int)status, status.ToString());

            if (status == DBStatus.NotFound)
            {
                return(NotFound());
            }
            else if (status == DBStatus.Forbidden)
            {
                return(Forbid());
            }
            else if (status == DBStatus.NotModified)
            {
                return(BadRequest(new BadResponseDTO {
                    Status = (int)status, Errors = new Errors {
                        Message = new List <string> {
                            status.ToString()
                        }
                    }
                }));
            }
            else
            {
                return(Ok(responseStatusDTO));
            }
        }
        public async Task <IActionResult> CreateStory([FromBody] RequestStoryDTO storyDTO)
        {
            string   userId = HttpContext.User.Claims.FirstOrDefault(c => c.Type == System.Security.Claims.ClaimTypes.Sid).Value;
            DBStatus status = await storiesService.CreateStoryAsync(storyDTO, userId);

            ResponseStatusDTO responseStatusDTO = new ResponseStatusDTO((int)status, status.ToString());

            if (status == DBStatus.Failed)
            {
                return(BadRequest(new BadResponseDTO {
                    Status = (int)status, Errors = new Errors {
                        Message = new List <string> {
                            status.ToString()
                        }
                    }
                }));
            }
            else
            {
                return(CreatedAtAction(nameof(GetStory), new { storyId = storyDTO.StoryId }, null));
            }
        }
예제 #6
0
        //Create UI To show status
        private static void StatusItem(string dbName, DBStatus status, StackPanel container)
        {
            var bc = new BrushConverter();

            Canvas c = new Canvas();

            container.Children.Add(c);
            c.Height     = 30;
            c.Margin     = new Thickness(1, 1, 1, 1);
            c.Background = (System.Windows.Media.Brush)bc.ConvertFrom("#FF323232");

            Label l1 = new Label();

            c.Children.Add(l1);
            l1.HorizontalContentAlignment = HorizontalAlignment.Center;
            l1.VerticalContentAlignment   = VerticalAlignment.Center;
            l1.HorizontalAlignment        = HorizontalAlignment.Left;
            l1.VerticalAlignment          = VerticalAlignment.Top;
            l1.Foreground = System.Windows.Media.Brushes.White;
            l1.Content    = dbName;
            l1.FontSize   = 11;
            l1.Width      = 118;
            l1.Height     = c.Height;

            Label statusl = new Label();

            c.Children.Add(statusl);
            statusl.HorizontalContentAlignment = HorizontalAlignment.Center;
            statusl.VerticalContentAlignment   = VerticalAlignment.Center;
            statusl.HorizontalAlignment        = HorizontalAlignment.Left;
            statusl.VerticalAlignment          = VerticalAlignment.Top;
            statusl.SetValue(Canvas.LeftProperty, 118.0);
            statusl.Foreground = System.Windows.Media.Brushes.White;
            statusl.Content    = status.ToString();
            statusl.FontSize   = 11;
            statusl.Width      = 80;
            statusl.Height     = c.Height;
        }
예제 #7
0
 internal static InvalidOperationException UnexpectedStatusValue(DBStatus status)
 {
     return(ADP.DataAdapter(SR.Format(SR.OleDb_UnexpectedStatusValue, status.ToString())));
 }
예제 #8
0
        // OleDbCommand
        internal static void CommandParameterStatus(StringBuilder builder, int index, DBStatus status)
        {
            switch (status)
            {
            case DBStatus.S_OK:
            case DBStatus.S_ISNULL:
            case DBStatus.S_IGNORE:
                break;

            case DBStatus.E_BADACCESSOR:
                builder.Append(SR.Format(SR.OleDb_CommandParameterBadAccessor, index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            case DBStatus.E_CANTCONVERTVALUE:
                builder.Append(SR.Format(SR.OleDb_CommandParameterCantConvertValue, index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            case DBStatus.E_SIGNMISMATCH:
                builder.Append(SR.Format(SR.OleDb_CommandParameterSignMismatch, index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            case DBStatus.E_DATAOVERFLOW:
                builder.Append(SR.Format(SR.OleDb_CommandParameterDataOverflow, index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            case DBStatus.E_CANTCREATE:
                Debug.Assert(false, "CommandParameterStatus: unexpected E_CANTCREATE");
                goto default;

            case DBStatus.E_UNAVAILABLE:
                builder.Append(SR.Format(SR.OleDb_CommandParameterUnavailable, index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            case DBStatus.E_PERMISSIONDENIED:
                Debug.Assert(false, "CommandParameterStatus: unexpected E_PERMISSIONDENIED");
                goto default;

            case DBStatus.E_INTEGRITYVIOLATION:
                Debug.Assert(false, "CommandParameterStatus: unexpected E_INTEGRITYVIOLATION");
                goto default;

            case DBStatus.E_SCHEMAVIOLATION:
                Debug.Assert(false, "CommandParameterStatus: unexpected E_SCHEMAVIOLATION");
                goto default;

            case DBStatus.E_BADSTATUS:
                Debug.Assert(false, "CommandParameterStatus: unexpected E_BADSTATUS");
                goto default;

            case DBStatus.S_DEFAULT:
                builder.Append(SR.Format(SR.OleDb_CommandParameterDefault, index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            default:
                builder.Append(SR.Format(SR.OleDb_CommandParameterError, index.ToString(CultureInfo.InvariantCulture), status.ToString()));
                builder.Append(Environment.NewLine);
                break;
            }
        }
예제 #9
0
 static internal InvalidOperationException UnexpectedStatusValue(DBStatus status) {
     return ADP.DataAdapter(Res.GetString(Res.OleDb_UnexpectedStatusValue, status.ToString()));
 }
예제 #10
0
        // OleDbCommand
        static internal void CommandParameterStatus(StringBuilder builder, int index, DBStatus status) {
            switch (status) {
            case DBStatus.S_OK:
            case DBStatus.S_ISNULL:
            case DBStatus.S_IGNORE:
                break;

            case DBStatus.E_BADACCESSOR:
                builder.Append(Res.GetString(Res.OleDb_CommandParameterBadAccessor,index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            case DBStatus.E_CANTCONVERTVALUE:
                builder.Append(Res.GetString(Res.OleDb_CommandParameterCantConvertValue,index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            case DBStatus.E_SIGNMISMATCH:
                builder.Append(Res.GetString(Res.OleDb_CommandParameterSignMismatch,index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            case DBStatus.E_DATAOVERFLOW:
                builder.Append(Res.GetString(Res.OleDb_CommandParameterDataOverflow,index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            case DBStatus.E_CANTCREATE:
                Debug.Assert(false, "CommandParameterStatus: unexpected E_CANTCREATE");
                goto default;

            case DBStatus.E_UNAVAILABLE:
                builder.Append(Res.GetString(Res.OleDb_CommandParameterUnavailable,index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            case DBStatus.E_PERMISSIONDENIED:
                Debug.Assert(false, "CommandParameterStatus: unexpected E_PERMISSIONDENIED");
                goto default;

            case DBStatus.E_INTEGRITYVIOLATION:
                Debug.Assert(false, "CommandParameterStatus: unexpected E_INTEGRITYVIOLATION");
                goto default;

            case DBStatus.E_SCHEMAVIOLATION:
                Debug.Assert(false, "CommandParameterStatus: unexpected E_SCHEMAVIOLATION");
                goto default;

            case DBStatus.E_BADSTATUS:
                Debug.Assert(false, "CommandParameterStatus: unexpected E_BADSTATUS");
                goto default;

            case DBStatus.S_DEFAULT: // MDAC 66626
                builder.Append(Res.GetString(Res.OleDb_CommandParameterDefault,index.ToString(CultureInfo.InvariantCulture), ""));
                builder.Append(Environment.NewLine);
                break;

            default:
                builder.Append(Res.GetString(Res.OleDb_CommandParameterError, index.ToString(CultureInfo.InvariantCulture), status.ToString()));
                builder.Append(Environment.NewLine);
                break;
            }
        }
예제 #11
0
 static internal InvalidOperationException UnexpectedStatusValue(DBStatus status)
 {
     return(ADP.DataAdapter(Res.GetString(Res.OleDb_UnexpectedStatusValue, status.ToString())));
 }
 internal static InvalidOperationException UnexpectedStatusValue(DBStatus status)
 {
     return ADP.DataAdapter(Res.GetString("OleDb_UnexpectedStatusValue", new object[] { status.ToString() }));
 }
        internal static void CommandParameterStatus(StringBuilder builder, int index, DBStatus status)
        {
            switch (status)
            {
                case DBStatus.S_OK:
                case DBStatus.S_ISNULL:
                case DBStatus.S_IGNORE:
                    return;

                case DBStatus.E_BADACCESSOR:
                    builder.Append(Res.GetString("OleDb_CommandParameterBadAccessor", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                    builder.Append(Environment.NewLine);
                    return;

                case DBStatus.E_CANTCONVERTVALUE:
                    builder.Append(Res.GetString("OleDb_CommandParameterCantConvertValue", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                    builder.Append(Environment.NewLine);
                    return;

                case DBStatus.E_SIGNMISMATCH:
                    builder.Append(Res.GetString("OleDb_CommandParameterSignMismatch", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                    builder.Append(Environment.NewLine);
                    return;

                case DBStatus.E_DATAOVERFLOW:
                    builder.Append(Res.GetString("OleDb_CommandParameterDataOverflow", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                    builder.Append(Environment.NewLine);
                    return;

                case DBStatus.E_UNAVAILABLE:
                    builder.Append(Res.GetString("OleDb_CommandParameterUnavailable", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                    builder.Append(Environment.NewLine);
                    return;

                case DBStatus.S_DEFAULT:
                    builder.Append(Res.GetString("OleDb_CommandParameterDefault", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                    builder.Append(Environment.NewLine);
                    return;
            }
            builder.Append(Res.GetString("OleDb_CommandParameterError", new object[] { index.ToString(CultureInfo.InvariantCulture), status.ToString() }));
            builder.Append(Environment.NewLine);
        }
예제 #14
0
 internal static InvalidOperationException UnexpectedStatusValue(DBStatus status)
 {
     return(ADP.DataAdapter(Res.GetString("OleDb_UnexpectedStatusValue", new object[] { status.ToString() })));
 }
예제 #15
0
        internal static void CommandParameterStatus(StringBuilder builder, int index, DBStatus status)
        {
            switch (status)
            {
            case DBStatus.S_OK:
            case DBStatus.S_ISNULL:
            case DBStatus.S_IGNORE:
                return;

            case DBStatus.E_BADACCESSOR:
                builder.Append(Res.GetString("OleDb_CommandParameterBadAccessor", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                builder.Append(Environment.NewLine);
                return;

            case DBStatus.E_CANTCONVERTVALUE:
                builder.Append(Res.GetString("OleDb_CommandParameterCantConvertValue", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                builder.Append(Environment.NewLine);
                return;

            case DBStatus.E_SIGNMISMATCH:
                builder.Append(Res.GetString("OleDb_CommandParameterSignMismatch", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                builder.Append(Environment.NewLine);
                return;

            case DBStatus.E_DATAOVERFLOW:
                builder.Append(Res.GetString("OleDb_CommandParameterDataOverflow", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                builder.Append(Environment.NewLine);
                return;

            case DBStatus.E_UNAVAILABLE:
                builder.Append(Res.GetString("OleDb_CommandParameterUnavailable", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                builder.Append(Environment.NewLine);
                return;

            case DBStatus.S_DEFAULT:
                builder.Append(Res.GetString("OleDb_CommandParameterDefault", new object[] { index.ToString(CultureInfo.InvariantCulture), "" }));
                builder.Append(Environment.NewLine);
                return;
            }
            builder.Append(Res.GetString("OleDb_CommandParameterError", new object[] { index.ToString(CultureInfo.InvariantCulture), status.ToString() }));
            builder.Append(Environment.NewLine);
        }