Beispiel #1
0
        public async Task <IHttpActionResult> PutCertificateDetail(int id, CertificateDetailVM CertificateDetailVM)
        {
            CertificateDetail CertificateDetail = ConvertToDBModel(CertificateDetailVM);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != CertificateDetail.ID)
            {
                return(BadRequest());
            }

            db.Entry(CertificateDetail).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> PostCertificateDetail(CertificateDetailVM CertificateDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CertificateDetails.Add(ConvertToDBModel(CertificateDetail));
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = CertificateDetail.ID }, CertificateDetail));
        }
Beispiel #3
0
 private CertificateDetail ConvertToDBModel(CertificateDetailVM cd)
 {
     return(new CertificateDetail
     {
         ID = cd.ID,
         LoginID = cd.LoginID,
         Title = cd.Title,
         Institute = cd.Institute,
         FromYear = cd.FromYear,
         ToYear = cd.ToYear,
         HasNoExpiry = cd.HasNoExpiry,
         DisplayOrder = cd.DisplayOrder,
         UpdatedOn = cd.UpdatedOn
     });
 }