예제 #1
0
        public async Task <IActionResult> OnPost()
        {
            ApplicationUser user = await userManager.FindByIdAsync(UserId);

            if (user == null)
            {
                return(RedirectToPage("/NotFound"));
            }

            IList <string> existingRoles = await userManager.GetRolesAsync(user);

            var result = await userManager.RemoveFromRolesAsync(user, existingRoles);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", "Cannot remove user existing roles");
                return(Page());
            }

            result = await userManager.AddToRolesAsync(user, UserCheckList.Where(x => x.IsSelected == true).Select(y => y.RoleName));

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", "Cannot add selected roles to user");
                return(Page());
            }

            return(RedirectToPage("/Admin/ListUsers"));
        }
예제 #2
0
        public async Task <IActionResult> OnPost()
        {
            ApplicationUser user = await userManager.FindByIdAsync(UserId);

            if (user == null)
            {
                return(RedirectToPage("/NotFound"));
            }

            IList <Claim> existingClaims = await userManager.GetClaimsAsync(user);

            var result = await userManager.RemoveClaimsAsync(user, existingClaims);

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", "Cannot remove user existing claims");
                return(Page());
            }

            result = await userManager.AddClaimsAsync(user, UserCheckList.Where(r => r.IsSelected == true).Select(c => new Claim(c.ClaimType, c.ClaimValue)));

            if (!result.Succeeded)
            {
                ModelState.AddModelError("", "Cannot add selected claims to user");
                return(Page());
            }

            return(RedirectToPage("/Admin/ListUsers"));
        }
 public static UserCheckDTO ConvertToDTO(this UserCheckList model, IMapper _mapper)
 {
     return(new UserCheckDTO
     {
         Check = model.Check.Convert <Check, BaseCheck>(_mapper),
         Comment = model.Comment.Convert <Comment, BaseComment>(_mapper)
     });
 }
        public async ValueTask <IActionResult> Get(int id)
        {
            UserCheckList check = await _repo.Item()
                                  .Where(c => c.Id == id)
                                  .Include(c => c.Check)
                                  .Include(c => c.Comment)
                                  .FirstOrDefaultAsync();

            if (check != null)
            {
                UserCheckDTO model = check.ConvertToDTO(_mapper);

                return(Ok(model));
            }
            return(NotFound(new ErrorDTO {
                Message = "Item not found"
            }));
        }
        public async ValueTask <IActionResult> Post([FromBody] UserCheckBase model)
        {
            if (ModelState.IsValid)
            {
                UserCheckList userCheck = model.Convert <UserCheckBase, UserCheckList>(_mapper);
                (bool succeeded, UserCheckList addedUserCheck, string error) = await _repo.Add(userCheck);

                if (succeeded)
                {
                    return(Ok(addedUserCheck.Convert <UserCheckList, UserCheckBase>(_mapper)));
                }
                return(BadRequest(new ErrorDTO {
                    Message = error
                }));
            }
            return(BadRequest(new ErrorDTO {
                Errors = ModelState.Values.SelectMany(e => e.Errors).ToList()
            }));
        }
예제 #6
0
        public CreateDocument(String [] Section_1, String[] Section_2, String[] Section_3, String[] Section_4, String[] SignaturAndDate)
        {
            object oMissing  = System.Reflection.Missing.Value;
            object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */



            //Start Word and create a new document.

            Word._Application oWord;
            Word._Document    oDoc;
            oWord         = new Word.Application();
            oWord.Visible = false;
            oDoc          = oWord.Documents.Add(ref oMissing, ref oMissing,
                                                ref oMissing, ref oMissing);


            object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;

            //Section 0: Title Section
            Word.Paragraph Title_Section;
            Title_Section = oDoc.Content.Paragraphs.Add(ref oMissing);
            Title_Section.Range.Font.Size = 16;
            Title_Section.Range.Bold      = 1;
            Title_Section.Range.Text      = "e-Commerce/EDI SI5 Promotion Check List";
            Title_Section.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
            Title_Section.Range.InsertParagraphAfter();


            //Section 1: User Partner Section---------------------------------------------------------------------------------------------------------
            Word.Paragraph UserPartner_Section;
            UserPartner_Section            = oDoc.Content.Paragraphs.Add(ref oMissing);
            UserPartner_Section.Range.Text = "User: "******"\t\t");
            UserPartner_Section.Range.InsertAfter("Partner: " + Section_1[1]);
            UserPartner_Section.Range.InsertAfter("\t\t");
            UserPartner_Section.Range.InsertAfter("Date: " + Section_1[2]);
            UserPartner_Section.Range.InsertAfter("\n");
            UserPartner_Section.Range.InsertAfter("Title:  " + Section_1[3]);
            UserPartner_Section.Range.InsertAfter("\t\t");
            UserPartner_Section.Range.InsertAfter("Change Management Request Number: " + Section_1[4]);
            UserPartner_Section.Range.InsertParagraphAfter();



            //Section 2: User Signoff Checklist Section------------------------------------------------------------------------------------------------------
            Word.Table UserCheckList;
            Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
            UserCheckList = oDoc.Tables.Add(wrdRng, 10, 4, ref oMissing, ref oMissing);
            UserCheckList.Range.ParagraphFormat.SpaceAfter = 6;
            UserCheckList.AllowAutoFit = true;
            UserCheckList.Columns[1].SetWidth(oWord.CentimetersToPoints(6f), Word.WdRulerStyle.wdAdjustNone);
            UserCheckList.Range.Font.Size = 10;
            Word.Column first     = UserCheckList.Columns[1];
            int         checklist = 0;

            for (int r = 1; r <= 10; r++)
            {
                for (int c = 1; c <= 4; c++)
                {
                    UserCheckList.Cell(r, c).Range.Text = Section_2[checklist];
                    checklist++;
                }
            }



            //Section 3: User Signoff Checklist Section--------------------------------------------------------------------------------------------------------------
            //Insert another paragraph.
            Word.Paragraph oPara3;
            oRng                   = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
            oPara3                 = oDoc.Content.Paragraphs.Add(ref oRng);
            oPara3.Range.Text      = " ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
            oPara3.Range.Font.Bold = 0;
            oPara3.Range.Font.Size = 8;
            oPara3.Range.InsertParagraphAfter();

            Word.Table Checklist;

            wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
            oPara3.Range.Paragraphs.LineSpacing = 10f;
            Checklist = oDoc.Tables.Add(wrdRng, 15, 4, ref oMissing, ref oMissing);
            Checklist.Range.ParagraphFormat.SpaceAfter = 6;
            Checklist.Columns[1].SetWidth(oWord.CentimetersToPoints(5f), Word.WdRulerStyle.wdAdjustNone);
            Checklist.AllowAutoFit = true;

            checklist = 0;
            for (int r = 1; r <= 15; r++)
            {
                for (int c = 1; c <= 4; c++)
                {
                    Checklist.Cell(r, c).Range.Text = Section_3[checklist];
                    checklist++;
                }
            }

            //Section 4: Schedule
            //Insert another paragraph.
            Word.Paragraph oPara4;
            oRng   = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
            oPara4 = oDoc.Content.Paragraphs.Add(ref oRng);
            oPara4.Range.Font.Size = 8;
            oPara4.Range.Text      = "--------------------------------------------------------------------------------------------------------------------------------------------------------";
            oPara4.Range.Font.Bold = 0;

            oPara4.Range.InsertParagraphAfter();



            Word.Table FinalCheckList;

            wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
            oPara4.Range.Paragraphs.LineSpacing = 10f;
            FinalCheckList = oDoc.Tables.Add(wrdRng, 3, 4, ref oMissing, ref oMissing);
            FinalCheckList.Range.ParagraphFormat.SpaceAfter = 6;
            FinalCheckList.Columns[1].SetWidth(oWord.CentimetersToPoints(5f), Word.WdRulerStyle.wdAdjustNone);
            FinalCheckList.AllowAutoFit = true;



            checklist = 0;
            for (int r = 1; r <= 3; r++)
            {
                for (int c = 1; c <= 4; c++)
                {
                    FinalCheckList.Cell(r, c).Range.Text = Section_4[checklist];
                    checklist++;
                }
            }


            //Signature and Date Section
            //Insert another paragraph.
            Word.Paragraph SignatureAndDate_Section;
            oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
            SignatureAndDate_Section = oDoc.Content.Paragraphs.Add(ref oRng);
            SignatureAndDate_Section.Range.Font.Bold = 0;
            SignatureAndDate_Section.Range.InsertParagraphAfter();
            SignatureAndDate_Section.Range.Text = "\n\t\t\t\t\t\t\tProject Manager: " + SignaturAndDate[0];
            SignatureAndDate_Section.Range.InsertAfter("\n\n");
            SignatureAndDate_Section.Range.InsertAfter("\t\t\t\t\t\t\tCompletion Date: " + SignaturAndDate[1]);
            String filename = @"C:\SharePoint Upload\Checklist_" + Section_2[37].Replace(" ", "") + "_" + DateTime.Now.ToString("yyyyMMdd") + ".docx";

            oWord.ActiveDocument.SaveAs2(filename);//Grabs the Implementation from Post Implementation
            oWord.ActiveDocument.Close();
        }