Esempio n. 1
0
        public async Task <IActionResult> PutPmtctData(string id, PmtctData pmtctData)
        {
            if (id != pmtctData.NambaMshiriki01)
            {
                return(BadRequest());
            }

            _context.Entry(pmtctData).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PmtctDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("ID,InitiatedART401,InitiatedARTDate401," +
                                                       "DeliveryFacility402,DeliveryFacilityDate402," +
                                                       "EarlyBirth403a,EarlyBirthDate403a,InfantHIVstatus403b,MotherResults403c," +
                                                       "MotherResultsDate403c,InfantBreastfeeding404a,InfantBreastfeedingDate404a," +
                                                       "RemarksName,NambaMshiriki01,UserId,Wilaya02,TareheMahojiano03," +
                                                       "Kituo04,JinaAnayehoji05,Ngazikituo06,MdaKuishiZanzibar109,KiwangoElimu102,Umri101," +
                                                       "WilayaUnayoishi107,IdadiMimba106,HaliNdoa103,KipatoMwezi104,Kazi105,NjeZanzibar108," +
                                                       "KilomitaKituo201,KilomitaUjazo202,HudumaUjauzito203,UgumuKliniki204a,HudumaHapa205," +
                                                       "BasiMbaliAfya204b_1,UgumuUsafiriUmma204b_2,KukosaNauli204b_3,MsafaraMrefu204b_4," +
                                                       "AnaishiMbaliBasi204b_5,AnaishiMbaliAfya204b_6,Mengine204b_7,TajaMengine204b," +
                                                       "UmepataHapaHuduma206,UmriMimba301,MwakaVVU302,MdaVVU303,DawaVVU304a,LiniDawaVVU304b,CTC304c")] PmtctData pmtctData)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    pmtctData.CreatedDate = DateTime.Now;

                    _context.Add(pmtctData);
                    await _context.SaveChangesAsync();

                    _logger.LogInformation(LoggingEvents.InsertItem, "Mteja {Id} Created by {user}", pmtctData.ID, User.Identity.Name);

                    return(RedirectToAction(nameof(Create)));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save a record. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator, Watch 'Namba ya Mshiriki' Must be unique.");
            }
            return(View(pmtctData));
        }
Esempio n. 3
0
        public async Task <ActionResult <PmtctData> > PostPmtctData(PmtctData pmtctData)
        {
            _context.Pmt.Add(pmtctData);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (PmtctDataExists(pmtctData.NambaMshiriki01))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetPmtctData", new { id = pmtctData.NambaMshiriki01 }, pmtctData));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,InitiatedART401,InitiatedARTDate401," +
                                                             "DeliveryFacility402,DeliveryFacilityDate402," +
                                                             "EarlyBirth403a,EarlyBirthDate403a,InfantHIVstatus403b,MotherResults403c," +
                                                             "MotherResultsDate403c,InfantBreastfeeding404a,InfantBreastfeedingDate404a," +
                                                             "RemarksName,NambaMshiriki01,UserId,Wilaya02,TareheMahojiano03,Kituo04,JinaAnayehoji05,Ngazikituo06,MdaKuishiZanzibar109,KiwangoElimu102,Umri101,WilayaUnayoishi107,IdadiMimba106,HaliNdoa103,KipatoMwezi104,Kazi105,NjeZanzibar108,KilomitaKituo201,KilomitaUjazo202,HudumaUjauzito203,UgumuKliniki204a,HudumaHapa205,BasiMbaliAfya204b_1,UgumuUsafiriUmma204b_2,KukosaNauli204b_3,MsafaraMrefu204b_4,AnaishiMbaliBasi204b_5,AnaishiMbaliAfya204b_6,Mengine204b_7,TajaMengine204b,UmepataHapaHuduma206,UmriMimba301,MwakaVVU302,MdaVVU303,DawaVVU304a,LiniDawaVVU304b,CTC304c")] PmtctData pmtctData)
        {
            if (id != pmtctData.ID)
            {
                _logger.LogWarning(LoggingEvents.GetItemNotFound, "Update({Id}) NOT FOUND", id);
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pmtctData);
                    await _context.SaveChangesAsync();

                    _logger.LogInformation(LoggingEvents.UpdateItem, "Item {Id} Updated", pmtctData.ID);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PmtctDataExists(pmtctData.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pmtctData));
        }