Esempio n. 1
0
        private void ProcessSave()
        {
            var currentTime = DateTimeOffset.UtcNow;

            foreach (var item in ChangeTracker.Entries()
                     .Where(e => e.State == EntityState.Added && e.Entity is EntityData))
            {
                var entidad = item.Entity as EntityData;
                entidad.CreatedDate    = currentTime;
                entidad.CreatedByUser  = currentUserService.GetCurrentUsername();
                entidad.ModifiedDate   = currentTime;
                entidad.ModifiedByUser = currentUserService.GetCurrentUsername();
            }

            foreach (var item in ChangeTracker.Entries()
                     .Where(predicate: e => e.State == EntityState.Modified && e.Entity is EntityData))
            {
                var entidad = item.Entity as EntityData;
                entidad.ModifiedDate   = currentTime;
                entidad.Edited         = true;
                entidad.ModifiedByUser = currentUserService.GetCurrentUsername();
                item.Property(nameof(entidad.CreatedDate)).IsModified   = false;
                item.Property(nameof(entidad.CreatedByUser)).IsModified = false;
            }
        }
Esempio n. 2
0
 public GetGameSessionsListQueryHandler(IUserManagerService userManager, ICurrentUserService currentUser, IFiefAppDbContext context, IMapper mapper)
 {
     _userManager = userManager;
     _context     = context;
     _mapper      = mapper;
     _currentUser = currentUser.GetCurrentUsername();
 }
Esempio n. 3
0
 public Handler(IFiefAppDbContext context, IMediator mediator, ICurrentUserService userService, IMapper mapper)
 {
     _context  = context;
     _mediator = mediator;
     _mapper   = mapper;
     _user     = userService.GetCurrentUsername();
 }
Esempio n. 4
0
 public Handler(IFiefAppDbContext context, IMediator mediator, IUserManagerService userManager, ICurrentUserService currentUser)
 {
     _context     = context;
     _mediator    = mediator;
     _userManager = userManager;
     _user        = currentUser.GetCurrentUsername();
 }
        public override async Task <int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            foreach (var entry in ChangeTracker.Entries <AuditableEntity>())
            {
                switch (entry.State)
                {
                case EntityState.Added:
                    entry.Entity.CreatedBy = _currentUserService.GetCurrentUsername() ?? "system";
                    entry.Entity.Created   = DateTime.UtcNow;
                    break;

                case EntityState.Modified:
                    entry.Entity.LastModifiedBy = _currentUserService.GetCurrentUsername() ?? "system";
                    entry.Entity.LastModified   = DateTime.UtcNow;
                    break;
                }
            }
            return(await base.SaveChangesAsync(cancellationToken));
        }
Esempio n. 6
0
            public async Task <User> Handle(Query request, CancellationToken cancellationToken)
            {
                var user = await _userManager.FindByNameAsync(_currentUserService.GetCurrentUsername());

                return(new User
                {
                    DisplayName = user.DisplayName,
                    Username = user.UserName,
                    Token = _jwtGenerator.CreateToken(user),
                    Image = null
                });
            }
Esempio n. 7
0
        // GET: FKMTOTOKWANZA
        public async Task <IActionResult> Index()
        {
            bool isAdmin = User.IsInRole("admin");

            if (isAdmin)
            {
                return(View(await _context.FKMTOTO.ToListAsync()));
            }
            else
            {
                return(View(await _context.FKMTOTO.Where(p => p.CreatedByUser == _currentUserService.GetCurrentUsername()).ToListAsync()));
            }
        }
Esempio n. 8
0
        public async Task <ActionResult <IEnumerable <PmtctData> > > GetPmt()
        {
            //return await _context.Pmt.ToListAsync();
            bool isSuperUser = User.IsInRole("admin") || User.IsInRole("analyst");

            if (isSuperUser)
            {
                return(await _context.Pmt.ToListAsync());
            }
            else
            {
                return(await _context.Pmt.Where(p => p.CreatedByUser == currentUserService.GetCurrentUsername()).ToListAsync());
            }
        }
Esempio n. 9
0
        // GET: Pmtct
        public async Task <IActionResult> Index()
        {
            using (_logger.BeginScope("Message {HoleValue}", DateTime.Now))
            {
                bool isAdmin = User.IsInRole("admin") || User.IsInRole("analyst");

                if (isAdmin)
                {
                    _logger.LogInformation(LoggingEvents.GetItem, "Listing all items");
                    return(View(await _context.Pmt.ToListAsync()));
                }
                else
                {
                    _logger.LogInformation(LoggingEvents.GetItem, "Listing all items");
                }
                return(View(await _context.Pmt.Where(p => p.CreatedByUser == currentUserService.GetCurrentUsername()).ToListAsync()));
            }
        }
Esempio n. 10
0
        public async Task <ActionResult> ExcelDoc()
        {
            bool isSuperUser = User.IsInRole("admin") || User.IsInRole("analyst");
            List <Pmtct.Models.PmtctFollowUp> pmtctUp = new List <PmtctFollowUp>();

            if (isSuperUser)
            {
                pmtctUp = await _context.PmtctFollowUp.ToListAsync();

                using (var workbook = new XLWorkbook())
                {
                    var worksheet  = workbook.Worksheets.Add("pmtctDatas");
                    var currentRow = 1;
                    worksheet.Cell(currentRow, 1).Value  = "ID";
                    worksheet.Cell(currentRow, 2).Value  = "NambaMshiriki01";
                    worksheet.Cell(currentRow, 3).Value  = "TareheHudhurio";
                    worksheet.Cell(currentRow, 4).Value  = "HaliYako305a";
                    worksheet.Cell(currentRow, 5).Value  = "Mwenza305b1";
                    worksheet.Cell(currentRow, 6).Value  = "Mwanafamiliaa305b2";
                    worksheet.Cell(currentRow, 7).Value  = "Wazazi305b3";
                    worksheet.Cell(currentRow, 8).Value  = "Rafiki305b1";
                    worksheet.Cell(currentRow, 9).Value  = "Mfanyakazi305b5";
                    worksheet.Cell(currentRow, 10).Value = "Wengine305b6";
                    worksheet.Cell(currentRow, 11).Value = "Tajawengine305b7";
                    worksheet.Cell(currentRow, 12).Value = "Naogopakutengwa306a1";
                    worksheet.Cell(currentRow, 13).Value = "Naogopakuachwa306a2";
                    worksheet.Cell(currentRow, 14).Value = "kunyanyapaliwa306a2";
                    worksheet.Cell(currentRow, 15).Value = "BadosijaaminiVVUliwa306a4";
                    worksheet.Cell(currentRow, 16).Value = "Sinaninaemwamini306a6";
                    worksheet.Cell(currentRow, 17).Value = "Nyinginezo306a6";
                    worksheet.Cell(currentRow, 18).Value = "MpangoMtu306b";
                    worksheet.Cell(currentRow, 19).Value = "HaliMwenza307";
                    worksheet.Cell(currentRow, 20).Value = "KuhudumiwaTofautiVVU308a";
                    worksheet.Cell(currentRow, 21).Value = "Mwenza308b1";
                    worksheet.Cell(currentRow, 22).Value = "Mwanafamiliaa308b2";
                    worksheet.Cell(currentRow, 23).Value = "Wazazi308b3";
                    worksheet.Cell(currentRow, 24).Value = "Rafiki308b1";
                    worksheet.Cell(currentRow, 25).Value = "Mfanyakazi308b5";
                    worksheet.Cell(currentRow, 26).Value = "Mhudumu308b6";
                    worksheet.Cell(currentRow, 27).Value = "Wengine308b7";
                    worksheet.Cell(currentRow, 28).Value = "Tajawengine308b8";
                    worksheet.Cell(currentRow, 29).Value = "UmejiungaVVU309a";
                    worksheet.Cell(currentRow, 30).Value = "NdioTaja309b";
                    worksheet.Cell(currentRow, 31).Value = "MamaMwambata310a";
                    worksheet.Cell(currentRow, 32).Value = "Ushauri310b1";
                    worksheet.Cell(currentRow, 33).Value = "Elimuafya310b2";
                    worksheet.Cell(currentRow, 34).Value = "Ufuatiliaji310b3";
                    worksheet.Cell(currentRow, 35).Value = "Nyinginezo310b4";
                    worksheet.Cell(currentRow, 36).Value = "Rufaa";
                    worksheet.Cell(currentRow, 37).Value = "TareheHudhurioLijalo";
                    worksheet.Cell(currentRow, 38).Value = "Ufuatiliaji";
                    worksheet.Cell(currentRow, 39).Value = "JinaMtoHuduma";
                    worksheet.Cell(currentRow, 40).Value = "CreatedByUser";
                    worksheet.Cell(currentRow, 41).Value = "CreatedDate";
                    worksheet.Cell(currentRow, 42).Value = "ModifiedByUser";
                    worksheet.Cell(currentRow, 43).Value = "ModifiedDate";
                    worksheet.Cell(currentRow, 44).Value = "Edited";

                    foreach (var item in pmtctUp)
                    {
                        currentRow++;
                        worksheet.Cell(currentRow, 1).Value  = item.ID;
                        worksheet.Cell(currentRow, 2).Value  = item.NambaMshiriki01;
                        worksheet.Cell(currentRow, 3).Value  = item.TareheHudhurio;
                        worksheet.Cell(currentRow, 4).Value  = item.HaliYako305a;
                        worksheet.Cell(currentRow, 5).Value  = item.Mwenza305b1;
                        worksheet.Cell(currentRow, 6).Value  = item.Mwanafamiliaa305b2;
                        worksheet.Cell(currentRow, 7).Value  = item.Wazazi305b3;
                        worksheet.Cell(currentRow, 8).Value  = item.Rafiki305b1;
                        worksheet.Cell(currentRow, 9).Value  = item.Mfanyakazi305b5;
                        worksheet.Cell(currentRow, 10).Value = item.Wengine305b6;
                        worksheet.Cell(currentRow, 11).Value = item.Tajawengine305b7;
                        worksheet.Cell(currentRow, 12).Value = item.Naogopakutengwa306a1;
                        worksheet.Cell(currentRow, 13).Value = item.Naogopakuachwa306a2;
                        worksheet.Cell(currentRow, 14).Value = item.kunyanyapaliwa306a2;
                        worksheet.Cell(currentRow, 15).Value = item.BadosijaaminiVVUliwa306a4;
                        worksheet.Cell(currentRow, 16).Value = item.Sinaninaemwamini306a6;
                        worksheet.Cell(currentRow, 17).Value = item.Nyinginezo306a6;
                        worksheet.Cell(currentRow, 18).Value = item.MpangoMtu306b;
                        worksheet.Cell(currentRow, 19).Value = item.HaliMwenza307;
                        worksheet.Cell(currentRow, 20).Value = item.KuhudumiwaTofautiVVU308a;
                        worksheet.Cell(currentRow, 21).Value = item.Mwenza308b1;
                        worksheet.Cell(currentRow, 22).Value = item.Mwanafamiliaa308b2;
                        worksheet.Cell(currentRow, 23).Value = item.Wazazi308b3;
                        worksheet.Cell(currentRow, 24).Value = item.Rafiki308b1;
                        worksheet.Cell(currentRow, 25).Value = item.Mfanyakazi308b5;
                        worksheet.Cell(currentRow, 26).Value = item.Mhudumu308b6;
                        worksheet.Cell(currentRow, 27).Value = item.Wengine308b7;
                        worksheet.Cell(currentRow, 28).Value = item.Tajawengine308b8;
                        worksheet.Cell(currentRow, 29).Value = item.UmejiungaVVU309a;
                        worksheet.Cell(currentRow, 30).Value = item.NdioTaja309b;
                        worksheet.Cell(currentRow, 31).Value = item.MamaMwambata310a;
                        worksheet.Cell(currentRow, 32).Value = item.Ushauri310b1;
                        worksheet.Cell(currentRow, 33).Value = item.Elimuafya310b2;
                        worksheet.Cell(currentRow, 34).Value = item.Ufuatiliaji310b3;
                        worksheet.Cell(currentRow, 35).Value = item.Nyinginezo310b4;
                        worksheet.Cell(currentRow, 36).Value = item.Rufaa;
                        worksheet.Cell(currentRow, 37).Value = item.TareheHudhurioLijalo;
                        worksheet.Cell(currentRow, 38).Value = item.Ufuatiliaji;
                        worksheet.Cell(currentRow, 39).Value = item.JinaMtoHuduma;
                        worksheet.Cell(currentRow, 40).Value = item.CreatedByUser;
                        worksheet.Cell(currentRow, 41).Value = item.CreatedDate;
                        worksheet.Cell(currentRow, 42).Value = item.ModifiedByUser;
                        worksheet.Cell(currentRow, 43).Value = item.ModifiedDate;
                        worksheet.Cell(currentRow, 44).Value = item.Edited;
                    }
                    using (var stream = new MemoryStream())
                    {
                        workbook.SaveAs(stream);
                        var content = stream.ToArray();
                        return(File(content, "application/vnd.openxlformats-officedocument.spreadsheetml.sheet"
                                    , "Pmtct_follow_up.xlsx"));
                    }
                }
            }
            else
            {
                pmtctUp = await _context.PmtctFollowUp.Where(p => p.CreatedByUser == currentUserService.GetCurrentUsername()).ToListAsync();

                using (var workbook = new XLWorkbook())
                {
                    var worksheet  = workbook.Worksheets.Add("pmtctDatas");
                    var currentRow = 1;
                    worksheet.Cell(currentRow, 1).Value  = "ID";
                    worksheet.Cell(currentRow, 2).Value  = "NambaMshiriki01";
                    worksheet.Cell(currentRow, 3).Value  = "TareheHudhurio";
                    worksheet.Cell(currentRow, 4).Value  = "HaliYako305a";
                    worksheet.Cell(currentRow, 5).Value  = "Mwenza305b1";
                    worksheet.Cell(currentRow, 6).Value  = "Mwanafamiliaa305b2";
                    worksheet.Cell(currentRow, 7).Value  = "Wazazi305b3";
                    worksheet.Cell(currentRow, 8).Value  = "Rafiki305b1";
                    worksheet.Cell(currentRow, 9).Value  = "Mfanyakazi305b5";
                    worksheet.Cell(currentRow, 10).Value = "Wengine305b6";
                    worksheet.Cell(currentRow, 11).Value = "Tajawengine305b7";
                    worksheet.Cell(currentRow, 12).Value = "Naogopakutengwa306a1";
                    worksheet.Cell(currentRow, 13).Value = "Naogopakuachwa306a2";
                    worksheet.Cell(currentRow, 14).Value = "kunyanyapaliwa306a2";
                    worksheet.Cell(currentRow, 15).Value = "BadosijaaminiVVUliwa306a4";
                    worksheet.Cell(currentRow, 16).Value = "Sinaninaemwamini306a6";
                    worksheet.Cell(currentRow, 17).Value = "Nyinginezo306a6";
                    worksheet.Cell(currentRow, 18).Value = "MpangoMtu306b";
                    worksheet.Cell(currentRow, 19).Value = "HaliMwenza307";
                    worksheet.Cell(currentRow, 20).Value = "KuhudumiwaTofautiVVU308a";
                    worksheet.Cell(currentRow, 21).Value = "Mwenza308b1";
                    worksheet.Cell(currentRow, 22).Value = "Mwanafamiliaa308b2";
                    worksheet.Cell(currentRow, 23).Value = "Wazazi308b3";
                    worksheet.Cell(currentRow, 24).Value = "Rafiki308b1";
                    worksheet.Cell(currentRow, 25).Value = "Mfanyakazi308b5";
                    worksheet.Cell(currentRow, 26).Value = "Mhudumu308b6";
                    worksheet.Cell(currentRow, 27).Value = "Wengine308b7";
                    worksheet.Cell(currentRow, 28).Value = "Tajawengine308b8";
                    worksheet.Cell(currentRow, 29).Value = "UmejiungaVVU309a";
                    worksheet.Cell(currentRow, 30).Value = "NdioTaja309b";
                    worksheet.Cell(currentRow, 31).Value = "MamaMwambata310a";
                    worksheet.Cell(currentRow, 32).Value = "Ushauri310b1";
                    worksheet.Cell(currentRow, 33).Value = "Elimuafya310b2";
                    worksheet.Cell(currentRow, 34).Value = "Ufuatiliaji310b3";
                    worksheet.Cell(currentRow, 35).Value = "Nyinginezo310b4";
                    worksheet.Cell(currentRow, 36).Value = "Rufaa";
                    worksheet.Cell(currentRow, 37).Value = "TareheHudhurioLijalo";
                    worksheet.Cell(currentRow, 38).Value = "Ufuatiliaji";
                    worksheet.Cell(currentRow, 39).Value = "JinaMtoHuduma";
                    worksheet.Cell(currentRow, 40).Value = "CreatedByUser";
                    worksheet.Cell(currentRow, 41).Value = "CreatedDate";
                    worksheet.Cell(currentRow, 42).Value = "ModifiedByUser";
                    worksheet.Cell(currentRow, 43).Value = "ModifiedDate";
                    worksheet.Cell(currentRow, 44).Value = "Edited";
                    foreach (var item in pmtctUp)
                    {
                        currentRow++;
                        worksheet.Cell(currentRow, 1).Value  = item.ID;
                        worksheet.Cell(currentRow, 2).Value  = item.NambaMshiriki01;
                        worksheet.Cell(currentRow, 3).Value  = item.TareheHudhurio;
                        worksheet.Cell(currentRow, 4).Value  = item.HaliYako305a;
                        worksheet.Cell(currentRow, 5).Value  = item.Mwenza305b1;
                        worksheet.Cell(currentRow, 6).Value  = item.Mwanafamiliaa305b2;
                        worksheet.Cell(currentRow, 7).Value  = item.Wazazi305b3;
                        worksheet.Cell(currentRow, 8).Value  = item.Rafiki305b1;
                        worksheet.Cell(currentRow, 9).Value  = item.Mfanyakazi305b5;
                        worksheet.Cell(currentRow, 10).Value = item.Wengine305b6;
                        worksheet.Cell(currentRow, 11).Value = item.Tajawengine305b7;
                        worksheet.Cell(currentRow, 12).Value = item.Naogopakutengwa306a1;
                        worksheet.Cell(currentRow, 13).Value = item.Naogopakuachwa306a2;
                        worksheet.Cell(currentRow, 14).Value = item.kunyanyapaliwa306a2;
                        worksheet.Cell(currentRow, 15).Value = item.BadosijaaminiVVUliwa306a4;
                        worksheet.Cell(currentRow, 16).Value = item.Sinaninaemwamini306a6;
                        worksheet.Cell(currentRow, 17).Value = item.Nyinginezo306a6;
                        worksheet.Cell(currentRow, 18).Value = item.MpangoMtu306b;
                        worksheet.Cell(currentRow, 19).Value = item.HaliMwenza307;
                        worksheet.Cell(currentRow, 20).Value = item.KuhudumiwaTofautiVVU308a;
                        worksheet.Cell(currentRow, 21).Value = item.Mwenza308b1;
                        worksheet.Cell(currentRow, 22).Value = item.Mwanafamiliaa308b2;
                        worksheet.Cell(currentRow, 23).Value = item.Wazazi308b3;
                        worksheet.Cell(currentRow, 24).Value = item.Rafiki308b1;
                        worksheet.Cell(currentRow, 25).Value = item.Mfanyakazi308b5;
                        worksheet.Cell(currentRow, 26).Value = item.Mhudumu308b6;
                        worksheet.Cell(currentRow, 27).Value = item.Wengine308b7;
                        worksheet.Cell(currentRow, 28).Value = item.Tajawengine308b8;
                        worksheet.Cell(currentRow, 29).Value = item.UmejiungaVVU309a;
                        worksheet.Cell(currentRow, 30).Value = item.NdioTaja309b;
                        worksheet.Cell(currentRow, 31).Value = item.MamaMwambata310a;
                        worksheet.Cell(currentRow, 32).Value = item.Ushauri310b1;
                        worksheet.Cell(currentRow, 33).Value = item.Elimuafya310b2;
                        worksheet.Cell(currentRow, 34).Value = item.Ufuatiliaji310b3;
                        worksheet.Cell(currentRow, 35).Value = item.Nyinginezo310b4;
                        worksheet.Cell(currentRow, 36).Value = item.Rufaa;
                        worksheet.Cell(currentRow, 37).Value = item.TareheHudhurioLijalo;
                        worksheet.Cell(currentRow, 38).Value = item.Ufuatiliaji;
                        worksheet.Cell(currentRow, 39).Value = item.JinaMtoHuduma;
                        worksheet.Cell(currentRow, 40).Value = item.CreatedByUser;
                        worksheet.Cell(currentRow, 41).Value = item.CreatedDate;
                        worksheet.Cell(currentRow, 42).Value = item.ModifiedByUser;
                        worksheet.Cell(currentRow, 43).Value = item.ModifiedDate;
                        worksheet.Cell(currentRow, 44).Value = item.Edited;
                    }
                    using (var stream = new MemoryStream())
                    {
                        workbook.SaveAs(stream);
                        var content = stream.ToArray();
                        return(File(content, "application/vnd.openxlformats-officedocument.spreadsheetml.sheet"
                                    , "Pmtct_follow_up.xlsx"));
                    }
                }
            }
        }
 public GetDetailedSubsidiaryQueryHandler(IFiefAppDbContext context, IMapper mapper, ICurrentUserService currentUser)
 {
     _context = context;
     _mapper  = mapper;
     _user    = currentUser.GetCurrentUsername();
 }
Esempio n. 12
0
 public CurrentUserQueryHandler(IUserManagerService userManager, ICurrentUserService currentUser)
 {
     _userManager = userManager;
     _currentUser = currentUser.GetCurrentUsername();
 }
Esempio n. 13
0
 public UpdateRoadCommandHandler(IFiefAppDbContext context, ICurrentUserService currentUser)
 {
     _context     = context;
     _currentUser = currentUser.GetCurrentUsername();
 }
Esempio n. 14
0
        public async Task <ActionResult> ExcelDoc()

        {
            bool isSuperUser = User.IsInRole("admin") || User.IsInRole("analyst");
            List <Pmtct.Models.PmtctData> pmtctDatas = new List <PmtctData>();

            if (isSuperUser)
            {
                pmtctDatas = await _context.Pmt.ToListAsync();

                using (var workbook = new XLWorkbook())
                {
                    var worksheet  = workbook.Worksheets.Add("pmtctDatas");
                    var currentRow = 1;


                    worksheet.Cell(currentRow, 1).Value  = "ID";
                    worksheet.Cell(currentRow, 2).Value  = "InitiatedART401";
                    worksheet.Cell(currentRow, 3).Value  = "InitiatedARTDate401";
                    worksheet.Cell(currentRow, 4).Value  = "DeliveryFacility402";
                    worksheet.Cell(currentRow, 5).Value  = "DeliveryFacilityDate402";
                    worksheet.Cell(currentRow, 6).Value  = "EarlyBirth403a";
                    worksheet.Cell(currentRow, 7).Value  = "EarlyBirthDate403a";
                    worksheet.Cell(currentRow, 8).Value  = "InfantHIVstatus403b";
                    worksheet.Cell(currentRow, 9).Value  = "MotherResults403c";
                    worksheet.Cell(currentRow, 10).Value = "MotherResultsDate403c";
                    worksheet.Cell(currentRow, 11).Value = "InfantBreastfeeding404a";
                    worksheet.Cell(currentRow, 12).Value = "InfantBreastfeedingDate404a";
                    worksheet.Cell(currentRow, 13).Value = "RemarksName";
                    worksheet.Cell(currentRow, 14).Value = "NambaMshiriki01";
                    worksheet.Cell(currentRow, 15).Value = "Wilaya02";
                    worksheet.Cell(currentRow, 16).Value = "TareheMahojiano03";
                    worksheet.Cell(currentRow, 17).Value = "Kituo04";
                    worksheet.Cell(currentRow, 18).Value = "JinaAnayehoji05";
                    worksheet.Cell(currentRow, 19).Value = "Ngazikituo06";
                    worksheet.Cell(currentRow, 20).Value = "Umri101";
                    worksheet.Cell(currentRow, 21).Value = "KiwangoElimu102";
                    worksheet.Cell(currentRow, 22).Value = "HaliNdoa103";
                    worksheet.Cell(currentRow, 23).Value = "KipatoMwezi104";
                    worksheet.Cell(currentRow, 24).Value = "Kazi105";
                    worksheet.Cell(currentRow, 25).Value = "IdadiMimba106";
                    worksheet.Cell(currentRow, 26).Value = "WilayaUnayoishi107";
                    worksheet.Cell(currentRow, 27).Value = "MdaKuishiZanzibar109";
                    worksheet.Cell(currentRow, 28).Value = "KilomitaKituo201";
                    worksheet.Cell(currentRow, 29).Value = "KilomitaUjazo202";
                    worksheet.Cell(currentRow, 30).Value = "UgumuKliniki204a";
                    worksheet.Cell(currentRow, 31).Value = "BasiMbaliAfya204b_1";
                    worksheet.Cell(currentRow, 32).Value = "UgumuUsafiriUmma204b_2";
                    worksheet.Cell(currentRow, 33).Value = "KukosaNauli204b_3";
                    worksheet.Cell(currentRow, 34).Value = "MsafaraMrefu204b_4";
                    worksheet.Cell(currentRow, 35).Value = "AnaishiMbaliBasi204b_5";
                    worksheet.Cell(currentRow, 36).Value = "AnaishiMbaliAfya204b_6";
                    worksheet.Cell(currentRow, 37).Value = "Mengine204b_7";
                    worksheet.Cell(currentRow, 38).Value = "TajaMengine204b";
                    worksheet.Cell(currentRow, 39).Value = "HudumaHapa205";
                    worksheet.Cell(currentRow, 40).Value = "UmepataHapaHuduma206";
                    worksheet.Cell(currentRow, 41).Value = "UmriMimba301";
                    worksheet.Cell(currentRow, 42).Value = "MwakaVVU302";
                    worksheet.Cell(currentRow, 43).Value = "MdaVVU303";
                    worksheet.Cell(currentRow, 44).Value = "DawaVVU304a";
                    worksheet.Cell(currentRow, 45).Value = "LiniDawaVVU304b";
                    worksheet.Cell(currentRow, 46).Value = "CTC304c";



                    foreach (var item in pmtctDatas)
                    {
                        currentRow++;
                        worksheet.Cell(currentRow, 1).Value  = item.ID;
                        worksheet.Cell(currentRow, 2).Value  = item.InitiatedART401;
                        worksheet.Cell(currentRow, 3).Value  = item.InitiatedARTDate401;
                        worksheet.Cell(currentRow, 4).Value  = item.DeliveryFacility402;
                        worksheet.Cell(currentRow, 5).Value  = item.DeliveryFacilityDate402;
                        worksheet.Cell(currentRow, 6).Value  = item.EarlyBirth403a;
                        worksheet.Cell(currentRow, 7).Value  = item.EarlyBirthDate403a;
                        worksheet.Cell(currentRow, 8).Value  = item.InfantHIVstatus403b;
                        worksheet.Cell(currentRow, 9).Value  = item.MotherResults403c;
                        worksheet.Cell(currentRow, 10).Value = item.MotherResultsDate403c;
                        worksheet.Cell(currentRow, 11).Value = item.InfantBreastfeeding404a;
                        worksheet.Cell(currentRow, 12).Value = item.InfantBreastfeedingDate404a;
                        worksheet.Cell(currentRow, 13).Value = item.RemarksName;
                        worksheet.Cell(currentRow, 14).Value = item.NambaMshiriki01;
                        worksheet.Cell(currentRow, 15).Value = item.Wilaya02;
                        worksheet.Cell(currentRow, 16).Value = item.TareheMahojiano03;
                        worksheet.Cell(currentRow, 17).Value = item.Kituo04;
                        worksheet.Cell(currentRow, 18).Value = item.JinaAnayehoji05;
                        worksheet.Cell(currentRow, 19).Value = item.Ngazikituo06;
                        worksheet.Cell(currentRow, 20).Value = item.Umri101;
                        worksheet.Cell(currentRow, 21).Value = item.KiwangoElimu102;
                        worksheet.Cell(currentRow, 22).Value = item.HaliNdoa103;
                        worksheet.Cell(currentRow, 23).Value = item.KipatoMwezi104;
                        worksheet.Cell(currentRow, 24).Value = item.Kazi105;
                        worksheet.Cell(currentRow, 25).Value = item.IdadiMimba106;
                        worksheet.Cell(currentRow, 26).Value = item.WilayaUnayoishi107;
                        worksheet.Cell(currentRow, 27).Value = item.MdaKuishiZanzibar109;
                        worksheet.Cell(currentRow, 28).Value = item.KilomitaKituo201;
                        worksheet.Cell(currentRow, 29).Value = item.KilomitaUjazo202;
                        worksheet.Cell(currentRow, 30).Value = item.UgumuKliniki204a;
                        worksheet.Cell(currentRow, 31).Value = item.BasiMbaliAfya204b_1;
                        worksheet.Cell(currentRow, 32).Value = item.UgumuUsafiriUmma204b_2;
                        worksheet.Cell(currentRow, 33).Value = item.KukosaNauli204b_3;
                        worksheet.Cell(currentRow, 34).Value = item.MsafaraMrefu204b_4;
                        worksheet.Cell(currentRow, 35).Value = item.AnaishiMbaliBasi204b_5;
                        worksheet.Cell(currentRow, 36).Value = item.AnaishiMbaliAfya204b_6;
                        worksheet.Cell(currentRow, 37).Value = item.Mengine204b_7;
                        worksheet.Cell(currentRow, 38).Value = item.TajaMengine204b;
                        worksheet.Cell(currentRow, 39).Value = item.HudumaHapa205;
                        worksheet.Cell(currentRow, 40).Value = item.UmepataHapaHuduma206;
                        worksheet.Cell(currentRow, 41).Value = item.UmriMimba301;
                        worksheet.Cell(currentRow, 42).Value = item.MwakaVVU302;
                        worksheet.Cell(currentRow, 43).Value = item.MdaVVU303;
                        worksheet.Cell(currentRow, 44).Value = item.DawaVVU304a;
                        worksheet.Cell(currentRow, 45).Value = item.LiniDawaVVU304b;
                        worksheet.Cell(currentRow, 46).Value = item.CTC304c;
                    }
                    using (var stream = new MemoryStream())
                    {
                        workbook.SaveAs(stream);
                        var content = stream.ToArray();
                        return(File(content, "application/vnd.openxlformats-officedocument.spreadsheetml.sheet"
                                    , "PmtctInfo.xlsx"));
                    }
                }
            }
            else
            {
                pmtctDatas = await _context.Pmt.Where(p => p.CreatedByUser == currentUserService.GetCurrentUsername()).ToListAsync();

                using (var workbook = new XLWorkbook())
                {
                    var worksheet  = workbook.Worksheets.Add("pmtctDatas");
                    var currentRow = 1;
                    worksheet.Cell(currentRow, 1).Value  = "ID";
                    worksheet.Cell(currentRow, 2).Value  = "InitiatedART401";
                    worksheet.Cell(currentRow, 3).Value  = "InitiatedARTDate401";
                    worksheet.Cell(currentRow, 4).Value  = "DeliveryFacility402";
                    worksheet.Cell(currentRow, 5).Value  = "DeliveryFacilityDate402";
                    worksheet.Cell(currentRow, 6).Value  = "EarlyBirth403a";
                    worksheet.Cell(currentRow, 7).Value  = "EarlyBirthDate403a";
                    worksheet.Cell(currentRow, 8).Value  = "InfantHIVstatus403b";
                    worksheet.Cell(currentRow, 9).Value  = "MotherResults403c";
                    worksheet.Cell(currentRow, 10).Value = "MotherResultsDate403c";
                    worksheet.Cell(currentRow, 11).Value = "InfantBreastfeeding404a";
                    worksheet.Cell(currentRow, 12).Value = "InfantBreastfeedingDate404a";
                    worksheet.Cell(currentRow, 13).Value = "RemarksName";
                    worksheet.Cell(currentRow, 14).Value = "NambaMshiriki01";
                    worksheet.Cell(currentRow, 15).Value = "Wilaya02";
                    worksheet.Cell(currentRow, 16).Value = "TareheMahojiano03";
                    worksheet.Cell(currentRow, 17).Value = "Kituo04";
                    worksheet.Cell(currentRow, 18).Value = "JinaAnayehoji05";
                    worksheet.Cell(currentRow, 19).Value = "Ngazikituo06";
                    worksheet.Cell(currentRow, 20).Value = "Umri101";
                    worksheet.Cell(currentRow, 21).Value = "KiwangoElimu102";
                    worksheet.Cell(currentRow, 22).Value = "HaliNdoa103";
                    worksheet.Cell(currentRow, 23).Value = "KipatoMwezi104";
                    worksheet.Cell(currentRow, 24).Value = "Kazi105";
                    worksheet.Cell(currentRow, 25).Value = "IdadiMimba106";
                    worksheet.Cell(currentRow, 26).Value = "WilayaUnayoishi107";
                    worksheet.Cell(currentRow, 27).Value = "MdaKuishiZanzibar109";
                    worksheet.Cell(currentRow, 28).Value = "KilomitaKituo201";
                    worksheet.Cell(currentRow, 29).Value = "KilomitaUjazo202";
                    worksheet.Cell(currentRow, 30).Value = "UgumuKliniki204a";
                    worksheet.Cell(currentRow, 31).Value = "BasiMbaliAfya204b_1";
                    worksheet.Cell(currentRow, 32).Value = "UgumuUsafiriUmma204b_2";
                    worksheet.Cell(currentRow, 33).Value = "KukosaNauli204b_3";
                    worksheet.Cell(currentRow, 34).Value = "MsafaraMrefu204b_4";
                    worksheet.Cell(currentRow, 35).Value = "AnaishiMbaliBasi204b_5";
                    worksheet.Cell(currentRow, 36).Value = "AnaishiMbaliAfya204b_6";
                    worksheet.Cell(currentRow, 37).Value = "Mengine204b_7";
                    worksheet.Cell(currentRow, 38).Value = "TajaMengine204b";
                    worksheet.Cell(currentRow, 39).Value = "HudumaHapa205";
                    worksheet.Cell(currentRow, 40).Value = "UmepataHapaHuduma206";
                    worksheet.Cell(currentRow, 41).Value = "UmriMimba301";
                    worksheet.Cell(currentRow, 42).Value = "MwakaVVU302";
                    worksheet.Cell(currentRow, 43).Value = "MdaVVU303";
                    worksheet.Cell(currentRow, 44).Value = "DawaVVU304a";
                    worksheet.Cell(currentRow, 45).Value = "LiniDawaVVU304b";
                    worksheet.Cell(currentRow, 46).Value = "CTC304c";


                    foreach (var item in pmtctDatas)
                    {
                        currentRow++;
                        worksheet.Cell(currentRow, 1).Value  = item.ID;
                        worksheet.Cell(currentRow, 2).Value  = item.InitiatedART401;
                        worksheet.Cell(currentRow, 3).Value  = item.InitiatedARTDate401;
                        worksheet.Cell(currentRow, 4).Value  = item.DeliveryFacility402;
                        worksheet.Cell(currentRow, 5).Value  = item.DeliveryFacilityDate402;
                        worksheet.Cell(currentRow, 6).Value  = item.EarlyBirth403a;
                        worksheet.Cell(currentRow, 7).Value  = item.EarlyBirthDate403a;
                        worksheet.Cell(currentRow, 8).Value  = item.InfantHIVstatus403b;
                        worksheet.Cell(currentRow, 9).Value  = item.MotherResults403c;
                        worksheet.Cell(currentRow, 10).Value = item.MotherResultsDate403c;
                        worksheet.Cell(currentRow, 11).Value = item.InfantBreastfeeding404a;
                        worksheet.Cell(currentRow, 12).Value = item.InfantBreastfeedingDate404a;
                        worksheet.Cell(currentRow, 13).Value = item.RemarksName;
                        worksheet.Cell(currentRow, 14).Value = item.NambaMshiriki01;
                        worksheet.Cell(currentRow, 15).Value = item.Wilaya02;
                        worksheet.Cell(currentRow, 16).Value = item.TareheMahojiano03;
                        worksheet.Cell(currentRow, 17).Value = item.Kituo04;
                        worksheet.Cell(currentRow, 18).Value = item.JinaAnayehoji05;
                        worksheet.Cell(currentRow, 19).Value = item.Ngazikituo06;
                        worksheet.Cell(currentRow, 20).Value = item.Umri101;
                        worksheet.Cell(currentRow, 21).Value = item.KiwangoElimu102;
                        worksheet.Cell(currentRow, 22).Value = item.HaliNdoa103;
                        worksheet.Cell(currentRow, 23).Value = item.KipatoMwezi104;
                        worksheet.Cell(currentRow, 24).Value = item.Kazi105;
                        worksheet.Cell(currentRow, 25).Value = item.IdadiMimba106;
                        worksheet.Cell(currentRow, 26).Value = item.WilayaUnayoishi107;
                        worksheet.Cell(currentRow, 27).Value = item.MdaKuishiZanzibar109;
                        worksheet.Cell(currentRow, 28).Value = item.KilomitaKituo201;
                        worksheet.Cell(currentRow, 29).Value = item.KilomitaUjazo202;
                        worksheet.Cell(currentRow, 30).Value = item.UgumuKliniki204a;
                        worksheet.Cell(currentRow, 31).Value = item.BasiMbaliAfya204b_1;
                        worksheet.Cell(currentRow, 32).Value = item.UgumuUsafiriUmma204b_2;
                        worksheet.Cell(currentRow, 33).Value = item.KukosaNauli204b_3;
                        worksheet.Cell(currentRow, 34).Value = item.MsafaraMrefu204b_4;
                        worksheet.Cell(currentRow, 35).Value = item.AnaishiMbaliBasi204b_5;
                        worksheet.Cell(currentRow, 36).Value = item.AnaishiMbaliAfya204b_6;
                        worksheet.Cell(currentRow, 37).Value = item.Mengine204b_7;
                        worksheet.Cell(currentRow, 38).Value = item.TajaMengine204b;
                        worksheet.Cell(currentRow, 39).Value = item.HudumaHapa205;
                        worksheet.Cell(currentRow, 40).Value = item.UmepataHapaHuduma206;
                        worksheet.Cell(currentRow, 41).Value = item.UmriMimba301;
                        worksheet.Cell(currentRow, 42).Value = item.MwakaVVU302;
                        worksheet.Cell(currentRow, 43).Value = item.MdaVVU303;
                        worksheet.Cell(currentRow, 44).Value = item.DawaVVU304a;
                        worksheet.Cell(currentRow, 45).Value = item.LiniDawaVVU304b;
                        worksheet.Cell(currentRow, 46).Value = item.CTC304c;
                    }
                    using (var stream = new MemoryStream())
                    {
                        workbook.SaveAs(stream);
                        var content = stream.ToArray();
                        return(File(content, "application/vnd.openxlformats-officedocument.spreadsheetml.sheet"
                                    , "PmtctInfo.xlsx"));
                    }
                }
            }
        }
Esempio n. 15
0
 public GetTaxsListQueryHandler(IFiefAppDbContext context, IMapper mapper, ICurrentUserService currentUser)
 {
     _context = context;
     _mapper  = mapper;
     _user    = currentUser.GetCurrentUsername();
 }
Esempio n. 16
0
        // GET: Bha
        public async Task <IActionResult> Index(string sortOrder, int currentFilter,
                                                int searchString, int?pageNumber)
        {
            bool isAdmin = User.IsInRole("admin");

            ViewData["CurrentSort"]  = sortOrder;
            ViewData["NameSortParm"] = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date";

            if (searchString != 0)
            {
                pageNumber = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            IQueryable <Bhamc> bh;

            ViewData["CurrentFilter"] = searchString;



            if (isAdmin)
            {
                bh = _context.Bhamc;
            }
            else
            {
                bh = _context.Bhamc.Where(p => p.CreatedByUser == _currentUserService.GetCurrentUsername());
            }



            if (searchString != 0)
            {
                bh = bh.Where(s => s.QuestionnaireNo == searchString);
            }


            switch (sortOrder)
            {
            case "name_desc":
                bh = bh.OrderByDescending(s => s.QuestionnaireNo);
                break;

            case "Date":
                bh = bh.OrderBy(s => s.CreatedDate);
                break;

            case "date_desc":
                bh = bh.OrderByDescending(s => s.CreatedByUser);
                break;

            default:
                bh = bh.OrderBy(s => s.CreatedDate);
                break;
            }

            int pageSize = 40;

            return(View(await PaginatedList <Bhamc> .CreateAsync(bh.AsNoTracking(), pageNumber ?? 1, pageSize)));

            //return View(await _context.Bhamc.ToListAsync());
        }
Esempio n. 17
0
      public async Task <ActionResult> CSV()
      {
          bool isSuperUser = User.IsInRole("admin") || User.IsInRole("analyst");

          List <Pmtct.Models.PmtctFollowUp> pmtctUp = new List <PmtctFollowUp>();
          var builder = new StringBuilder();

          if (isSuperUser)
          {
              pmtctUp = await _context.PmtctFollowUp.ToListAsync();

              builder.AppendLine("ID,NambaMshiriki01,TareheHudhurio,HaliYako305a,Mwenza305b1," +
                                 "Mwanafamiliaa305b2,Wazazi305b3,Rafiki305b1,Mfanyakazi305b5,Wengine305b6,Tajawengine305b7," +
                                 "Naogopakutengwa306a1,Naogopakuachwa306a2,kunyanyapaliwa306a2,BadosijaaminiVVUliwa306a4," +
                                 "Sinaninaemwamini306a6,Nyinginezo306a6,MpangoMtu306b,HaliMwenza307,KuhudumiwaTofautiVVU308a," +
                                 "Mwenza308b1,Mwanafamiliaa308b2,Wazazi308b3,Rafiki308b1,Mfanyakazi308b5,Mhudumu308b6,Wengine308b7," +
                                 "Tajawengine308b8,UmejiungaVVU309a,NdioTaja309b,MamaMwambata310a,Ushauri310b1,Elimuafya310b2," +
                                 "Ufuatiliaji310b3,Nyinginezo310b4,Rufaa,TareheHudhurioLijalo,Ufuatiliaji,JinaMtoHuduma,CreatedByUser," +
                                 "CreatedDate,ModifiedByUser,ModifiedDate,Edited");
              foreach (var item in pmtctUp)
              {
                  builder.AppendLine($"{item.ID},{item.NambaMshiriki01},{item.TareheHudhurio}," +
                                     $"{item.HaliYako305a},{item.Mwenza305b1},{item.Mwanafamiliaa305b2}," +
                                     $"{item.Wazazi305b3},{item.Rafiki305b1},{item.Mfanyakazi305b5}," +
                                     $"{item.Wengine305b6},{item.Tajawengine305b7},{item.Naogopakutengwa306a1}," +
                                     $"{item.Naogopakuachwa306a2},{item.kunyanyapaliwa306a2},{item.BadosijaaminiVVUliwa306a4}," +
                                     $"{item.Sinaninaemwamini306a6},{item.Nyinginezo306a6},{item.MpangoMtu306b}," +
                                     $"{item.HaliMwenza307},{item.KuhudumiwaTofautiVVU308a},{item.Mwenza308b1}," +
                                     $"{item.Mwanafamiliaa308b2},{item.Wazazi308b3},{item.Rafiki308b1}," +
                                     $"{item.Mfanyakazi308b5},{item.Mhudumu308b6},{item.Wengine308b7},{item.Tajawengine308b8}" +
                                     $"{item.UmejiungaVVU309a},{item.NdioTaja309b},{item.MamaMwambata310a}," +
                                     $"{item.Ushauri310b1},{item.Elimuafya310b2},{item.Ufuatiliaji},{item.Nyinginezo310b4}" +
                                     $"{item.Rufaa},{item.TareheHudhurioLijalo},{item.Ufuatiliaji}," +
                                     $"{item.JinaMtoHuduma},{item.CreatedByUser},{item.CreatedDate},{item.ModifiedByUser},{item.ModifiedDate}," +
                                     $"{item.Edited}");
              }


              return(File(Encoding.UTF8.GetBytes(builder.ToString()), "text/csv", "Pmtct_follow_up.csv"));
          }


          else
          {
              pmtctUp = await _context.PmtctFollowUp.Where(p => p.CreatedByUser == currentUserService.GetCurrentUsername()).ToListAsync();
          }

          builder.AppendLine("ID,NambaMshiriki01,TareheHudhurio,HaliYako305a,Mwenza305b1," +
                             "Mwanafamiliaa305b2,Wazazi305b3,Rafiki305b1,Mfanyakazi305b5,Wengine305b6,Tajawengine305b7," +
                             "Naogopakutengwa306a1,Naogopakuachwa306a2,kunyanyapaliwa306a2,BadosijaaminiVVUliwa306a4," +
                             "Sinaninaemwamini306a6,Nyinginezo306a6,MpangoMtu306b,HaliMwenza307,KuhudumiwaTofautiVVU308a," +
                             "Mwenza308b1,Mwanafamiliaa308b2,Wazazi308b3,Rafiki308b1,Mfanyakazi308b5,Mhudumu308b6,Wengine308b7," +
                             "Tajawengine308b8,UmejiungaVVU309a,NdioTaja309b,MamaMwambata310a,Ushauri310b1,Elimuafya310b2," +
                             "Ufuatiliaji310b3,Nyinginezo310b4,Rufaa,TareheHudhurioLijalo,Ufuatiliaji,JinaMtoHuduma,CreatedByUser," +
                             "CreatedDate,ModifiedByUser,ModifiedDate,Edited");
          foreach (var item in pmtctUp)
          {
              builder.AppendLine($"{item.ID},{item.NambaMshiriki01},{item.TareheHudhurio}," +
                                 $"{item.HaliYako305a},{item.Mwenza305b1},{item.Mwanafamiliaa305b2}," +
                                 $"{item.Wazazi305b3},{item.Rafiki305b1},{item.Mfanyakazi305b5}," +
                                 $"{item.Wengine305b6},{item.Tajawengine305b7},{item.Naogopakutengwa306a1}," +
                                 $"{item.Naogopakuachwa306a2},{item.kunyanyapaliwa306a2},{item.BadosijaaminiVVUliwa306a4}," +
                                 $"{item.Sinaninaemwamini306a6},{item.Nyinginezo306a6},{item.MpangoMtu306b}," +
                                 $"{item.HaliMwenza307},{item.KuhudumiwaTofautiVVU308a},{item.Mwenza308b1}," +
                                 $"{item.Mwanafamiliaa308b2},{item.Wazazi308b3},{item.Rafiki308b1}," +
                                 $"{item.Mfanyakazi308b5},{item.Mhudumu308b6},{item.Wengine308b7},{item.Tajawengine308b8}" +
                                 $"{item.UmejiungaVVU309a},{item.NdioTaja309b},{item.MamaMwambata310a}," +
                                 $"{item.Ushauri310b1},{item.Elimuafya310b2},{item.Ufuatiliaji},{item.Nyinginezo310b4}" +
                                 $"{item.Rufaa},{item.TareheHudhurioLijalo},{item.Ufuatiliaji}," +
                                 $"{item.JinaMtoHuduma},{item.CreatedByUser},{item.CreatedDate},{item.ModifiedByUser},{item.ModifiedDate}," +
                                 $"{item.Edited}");
          }


          return(File(Encoding.UTF8.GetBytes(builder.ToString()), "text/csv", "Pmtct_follow_up.csv"));
      }
Esempio n. 18
0
 public InitializeFiefQueryHandler(IFiefAppDbContext context, ICurrentUserService currentUser, IMapper mapper)
 {
     _context     = context;
     _mapper      = mapper;
     _currentUser = currentUser.GetCurrentUsername();
 }
Esempio n. 19
0
 public Handler(IMediator mediator, IUserManagerService userManager, ICurrentUserService currentUser)
 {
     _mediator    = mediator;
     _userManager = userManager;
     _userName    = currentUser.GetCurrentUsername();
 }
Esempio n. 20
0
        public async Task <ActionResult> CSV()

        {
            bool isSuperUser = User.IsInRole("admin") || User.IsInRole("analyst");
            List <Pmtct.Models.PmtctData> pmtctDatas = new List <PmtctData>();
            var builder = new StringBuilder();

            if (isSuperUser)
            {
                pmtctDatas = await _context.Pmt.ToListAsync();

                builder.AppendLine("ID,InitiatedART401,InitiatedARTDate401," +
                                   "DeliveryFacility402,DeliveryFacilityDate402," +
                                   "EarlyBirth403a,EarlyBirthDate403a,InfantHIVstatus403b,MotherResults403c," +
                                   "MotherResultsDate403c,InfantBreastfeeding404a,InfantBreastfeedingDate404a," +
                                   "RemarksName,NambaMshiriki01,Wilaya02,TareheMahojiano03," +
                                   "Kituo04,JinaAnayehoji05,Ngazikituo06,Umri101,KiwangoElimu102,HaliNdoa103,KipatoMwezi104," +
                                   "Kazi105,IdadiMimba106,WilayaUnayoishi107,MdaKuishiZanzibar109," +
                                   "KilomitaKituo201,KilomitaUjazo202,HudumaUjauzito203,UgumuKliniki204a," +
                                   "BasiMbaliAfya204b_1,UgumuUsafiriUmma204b_2,KukosaNauli204b_3,MsafaraMrefu204b_4," +
                                   "AnaishiMbaliBasi204b_5,AnaishiMbaliAfya204b_6,Mengine204b_7,TajaMengine204b,HudumaHapa205" +
                                   "UmepataHapaHuduma206,UmriMimba301,MwakaVVU302,MdaVVU303,DawaVVU304a,LiniDawaVVU304b,CTC304c");

                foreach (var item in pmtctDatas)
                {
                    builder.AppendLine($"{item.ID},{item.InitiatedART401},{item.InitiatedARTDate401}," +
                                       $"{item.DeliveryFacility402},{item.DeliveryFacilityDate402},{item.EarlyBirth403a}," +
                                       $"{item.EarlyBirthDate403a},{item.InfantHIVstatus403b}," +
                                       $"{item.MotherResults403c},{item.MotherResultsDate403c}," +
                                       $"{item.InfantBreastfeeding404a},{item.InfantBreastfeedingDate404a}," +
                                       $"{item.RemarksName},{item.NambaMshiriki01},{item.Wilaya02},{item.TareheMahojiano03}," +
                                       $"{item.Kituo04},{item.JinaAnayehoji05},{item.Ngazikituo06},{item.Umri101},{item.KiwangoElimu102}" +
                                       $"{item.HaliNdoa103},{item.KipatoMwezi104},{item.Kazi105},{item.MdaKuishiZanzibar109},{item.IdadiMimba106}" +
                                       $",{item.WilayaUnayoishi107},{item.KilomitaKituo201},{item.KilomitaUjazo202},{item.HudumaUjauzito203}," +
                                       $"{item.UgumuKliniki204a},{item.HudumaHapa205},{item.BasiMbaliAfya204b_1},{item.UgumuUsafiriUmma204b_2}," +
                                       $"{item.KukosaNauli204b_3},{item.MsafaraMrefu204b_4},{item.AnaishiMbaliBasi204b_5}," +
                                       $"{item.AnaishiMbaliAfya204b_6},{item.Mengine204b_7},{item.TajaMengine204b}," +
                                       $"{item.UmepataHapaHuduma206},{item.UmriMimba301},{item.MwakaVVU302},{item.MdaVVU303}," +
                                       $"{item.DawaVVU304a},{item.LiniDawaVVU304b},{item.CTC304c}");
                }
                return(File(Encoding.UTF8.GetBytes(builder.ToString()), "text/csv", "Pmtct.csv"));
            }

            else
            {
                pmtctDatas = await _context.Pmt.Where(p => p.CreatedByUser == currentUserService.GetCurrentUsername()).ToListAsync();
            }

            builder.AppendLine("ID,InitiatedART401,InitiatedARTDate401," +
                               "DeliveryFacility402,DeliveryFacilityDate402," +
                               "EarlyBirth403a,EarlyBirthDate403a,InfantHIVstatus403b,MotherResults403c," +
                               "MotherResultsDate403c,InfantBreastfeeding404a,InfantBreastfeedingDate404a," +
                               "RemarksName,NambaMshiriki01,Wilaya02,TareheMahojiano03," +
                               "Kituo04,JinaAnayehoji05,Ngazikituo06,Umri101,KiwangoElimu102,HaliNdoa103,KipatoMwezi104," +
                               "Kazi105,IdadiMimba106,WilayaUnayoishi107,MdaKuishiZanzibar109," +
                               "KilomitaKituo201,KilomitaUjazo202,HudumaUjauzito203,UgumuKliniki204a," +
                               "BasiMbaliAfya204b_1,UgumuUsafiriUmma204b_2,KukosaNauli204b_3,MsafaraMrefu204b_4," +
                               "AnaishiMbaliBasi204b_5,AnaishiMbaliAfya204b_6,Mengine204b_7,TajaMengine204b,HudumaHapa205" +
                               "UmepataHapaHuduma206,UmriMimba301,MwakaVVU302,MdaVVU303,DawaVVU304a,LiniDawaVVU304b,CTC304c");

            foreach (var item in pmtctDatas)
            {
                builder.AppendLine($"{item.ID},{item.InitiatedART401},{item.InitiatedARTDate401}," +
                                   $"{item.DeliveryFacility402},{item.DeliveryFacilityDate402},{item.EarlyBirth403a}," +
                                   $"{item.EarlyBirthDate403a},{item.InfantHIVstatus403b}," +
                                   $"{item.MotherResults403c},{item.MotherResultsDate403c}," +
                                   $"{item.InfantBreastfeeding404a},{item.InfantBreastfeedingDate404a}," +
                                   $"{item.RemarksName},{item.NambaMshiriki01},{item.Wilaya02},{item.TareheMahojiano03}," +
                                   $"{item.Kituo04},{item.JinaAnayehoji05},{item.Ngazikituo06},{item.Umri101},{item.KiwangoElimu102}" +
                                   $"{item.HaliNdoa103},{item.KipatoMwezi104},{item.Kazi105},{item.MdaKuishiZanzibar109},{item.IdadiMimba106}" +
                                   $",{item.WilayaUnayoishi107},{item.KilomitaKituo201},{item.KilomitaUjazo202},{item.HudumaUjauzito203}," +
                                   $"{item.UgumuKliniki204a},{item.HudumaHapa205},{item.BasiMbaliAfya204b_1},{item.UgumuUsafiriUmma204b_2}," +
                                   $"{item.KukosaNauli204b_3},{item.MsafaraMrefu204b_4},{item.AnaishiMbaliBasi204b_5}," +
                                   $"{item.AnaishiMbaliAfya204b_6},{item.Mengine204b_7},{item.TajaMengine204b}," +
                                   $"{item.UmepataHapaHuduma206},{item.UmriMimba301},{item.MwakaVVU302},{item.MdaVVU303}," +
                                   $"{item.DawaVVU304a},{item.LiniDawaVVU304b},{item.CTC304c}");
            }
            return(File(Encoding.UTF8.GetBytes(builder.ToString()), "text/csv", "Pmtct.csv"));
        }