Beispiel #1
0
        private static void Check_ForeignKeys(OrganisationsInput organisations)
        {
            var missingName = new BilingualItem("Missing", "Missing");

            //TODO: add unknown missing foreign keys

            // Accreditations
            List <int>           idAcs = organisations.Accreditors.Select(x => x.Id).ToList();
            List <Accreditation> missingAccreditors = organisations.Accreditations.FindAll(x => x.AccreditorId == 0 || !idAcs.Contains(x.AccreditorId));
            var missingAccreditor = new Accreditor {
                Id = 999999, Name = missingName
            };

            missingAccreditors.ForEach(x => x.Accreditor = missingAccreditor);

            // organisations.Accreditations.RemoveAll(x => x.AccreditorId == 0 || !idAcs.Contains(x.AccreditorId));

            // Organisations
            List <int> idLss = organisations.OrganisationLegalStatuses.Select(x => x.Id).ToList();
            var        missingLegalStatus = new OrganisationLegalStatus {
                Id = 999999, Name = missingName
            };
            List <Organisation> missingStatuses = organisations.Organisations.FindAll(x => x.LegalStatusId == 0 || !idLss.Contains(x.LegalStatusId));

            missingStatuses.ForEach(x => x.LegalStatus = missingLegalStatus);

            // organisations.Organisations.RemoveAll(x => x.LegalStatusId == 0 || !idLss.Contains(x.LegalStatusId));
        }
        public async Task <IActionResult> PutAccreditor([FromRoute] int id, [FromBody] Accreditor accreditor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != accreditor.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Beispiel #3
0
 public void DeleteAccreditor(int _accreditorID, bool isActive)
 {
     DlModel.Accreditor _acc = new Accreditor
     {
         AccreditorID = _accreditorID,
         IsActive     = isActive
     };
     _accreditorRepository.Update(_acc, acc => acc.IsActive);
 }
 public JsonResult DeleteAccreditor(Accreditor accreditor)
 {
     if (accreditor.IsActive == true)
     {
         accreditor.IsActive = false;
     }
     else
     {
         accreditor.IsActive = true;
     }
     _educationService.DeleteAccreditor(accreditor.AccreditorID, accreditor.IsActive);
     return(Json(accreditor, GlobalConst.Message.text_html));
 }
 public ActionResult Add(Accreditor accreditor)
 {
     if (accreditor.AccreditorID == 0)
     {
         accreditor.IsActive         = true;
         accreditor.OrganizationID   = HCRGCLIENT.OrganizationID;
         accreditor.OrganizationName = (_clientService.GetOrganizationByID(HCRGCLIENT.OrganizationID)).OrganizationName;
         accreditor.AccreditorID     = _educationService.AddAccreditor(Mapper.Map <HCRGUniversityMgtApp.NEPService.EducationService.Accreditor>(accreditor));
         accreditor.flag             = true;
     }
     else
     {
         int accreditorId = _educationService.UpdateAccreditor(Mapper.Map <HCRGUniversityMgtApp.NEPService.EducationService.Accreditor>(accreditor));
         accreditor.flag = false;
     }
     return(Json(accreditor, GlobalConst.Message.text_html));
 }
        public async Task <IActionResult> PostAccreditor([FromBody] Accreditor accreditor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Accreditors.Add(accreditor);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (AccreditorExists(accreditor.Id))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                throw;
            }

            return(CreatedAtAction("GetAccreditor", new { id = accreditor.Id }, accreditor));
        }
Beispiel #7
0
 public void Update(Accreditor obj)
 {
     throw new System.NotImplementedException();
 }