public void Update(string newPhotoName, ApplicableStandards oldAppStand)
        {
            var targetAppStand = this.GetByKey(oldAppStand);

            targetAppStand.PhotoName = newPhotoName;
            _context.SaveChanges();
        }
        public void Delete(ApplicableStandards ec)
        {
            var targetAppStand = this.GetByKey(ec);

            _context.ApplicableStandards.Remove(targetAppStand);
            _context.SaveChanges();
        }
Exemple #3
0
 public IActionResult Update(string newPhotoName, [FromBody] ApplicableStandards oldappStand)
 {
     try{
         _aStandardService.Update(newPhotoName, oldappStand);
         return(Ok(new { message = "Updated." }));
     }
     catch (AppException ex) {
         return(BadRequest(new { message = ex.Message }));
     }
 }
Exemple #4
0
 public IActionResult Delete([FromBody] ApplicableStandards ec)
 {
     try{
         _aStandardService.Delete(ec);
         return(Ok(ec));
     }
     catch (AppException ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
 }
        public void CheckValues(ApplicableStandards ec)
        {
            if (string.IsNullOrWhiteSpace(ec.DataLink))
            {
                throw new AppException("DataLink is required to finish inserting this record.");
            }

            if (string.IsNullOrEmpty(ec.ProjectNum.ToString()))
            {
                throw new AppException("Project Number is required to finish inserting this record.");
            }
        }
        public ApplicableStandards GetByKey(ApplicableStandards ec)
        {
            CheckValues(ec);
            var targetAppStand = _context.ApplicableStandards.SingleOrDefault(x =>
                                                                              (x.ProjectNum == ec.ProjectNum && x.DataLink == ec.DataLink));

            if (targetAppStand == null)
            {
                throw new AppException($"Applicable Standard with Data Link:'{ec.DataLink}' and Project Number:'{ec.ProjectNum}' DNE.");
            }
            return(targetAppStand);
        }
Exemple #7
0
 public IActionResult Create([FromBody] ApplicableStandards ec)
 {
     try
     {
         var newappStand = _aStandardService.Create(ec);
         return(Ok(newappStand));
     }
     catch (AppException ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
 }
        public ApplicableStandards Create(ApplicableStandards ec)
        {
            var checkObj = _context.ApplicableStandards.SingleOrDefault(x => x.ProjectNum == ec.ProjectNum && x.DataLink == ec.DataLink);

            if (checkObj != null)
            {
                throw new AppException($"Applicable Standard already exists for Link:{ec.DataLink} and Project Nubmer:{ec.ProjectNum}");
            }

            this.CheckValues(ec);
            _context.ApplicableStandards.Add(ec);
            _context.SaveChanges();
            return(ec);
        }