Beispiel #1
0
        public async Task <IActionResult> Create(EducationDetailEditDto qualification)
        {
            var qualificationtoDb = _mapper.Map <Mem_EducationDetail>(qualification);

            qualificationtoDb.CDate    = DateTime.UtcNow;
            qualificationtoDb.MemberId = UserId;
            await _db.Mem_EducationDetails.AddAsync(qualificationtoDb);

            try
            {
                await _db.SaveChangesAsync();

                return(Ok(new { success = "Success" }));
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Delete(EducationDetailEditDto qualification)
        {
            var qualificationInDb = _db.Mem_EducationDetails.Find(qualification.Id);

            if (qualificationInDb == null || qualificationInDb.MemberId != UserId)
            {
                return(NotFound());
            }
            _db.Entry(qualificationInDb).State = EntityState.Deleted;
            try
            {
                await _db.SaveChangesAsync();

                return(Ok(new { success = "Success" }));
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public async Task <IActionResult> Update(EducationDetailEditDto qualification)
        {
            try
            {
                var qualificationInDb = _db.Mem_EducationDetails.Find(qualification.Id);
                if (qualificationInDb == null || qualificationInDb.MemberId != UserId)
                {
                    return(NotFound());
                }
                var qualificationEdited = _mapper.Map(qualification, qualificationInDb);
                _db.Update(qualificationEdited);

                await _db.SaveChangesAsync();

                return(Ok(new { success = "Success" }));
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }