コード例 #1
0
        public OtherQualificationDTO PostAddOtherQualification([FromBody] OtherQualificationDTO OtherQualificationModel)
        {
            var email = HttpContext.Current.User.Identity.Name;

            OtherQualification otherQualification = null;

            if (OtherQualificationModel.Id != Guid.Empty)
            {
                otherQualification = db.OtherQualifications.Where(x => x.Id == OtherQualificationModel.Id).FirstOrDefault();;
            }
            else
            {
                otherQualification    = new OtherQualification();
                otherQualification.Id = Guid.NewGuid();
            }

            otherQualification.Name        = OtherQualificationModel.Name;
            otherQualification.UserProfile = db.UserProfiles.FirstOrDefault(usr => usr.Email == email);

            if (otherQualification == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            if (OtherQualificationModel.Id == Guid.Empty)
            {
                db.OtherQualifications.Add(otherQualification);
            }

            db.SaveChanges();

            OtherQualificationDTO otherQualificationDTO = MapperFacade.MapperConfiguration.Map <OtherQualification, OtherQualificationDTO>(otherQualification);

            return(otherQualificationDTO);
        }
コード例 #2
0
        public OtherQualificationDTO PostDeleteOtherQualification(OtherQualificationDTO OtherQualificationData)
        {
            OtherQualification deletedEntry = new OtherQualification();

            deletedEntry = db.OtherQualifications.Where(x => x.Id == OtherQualificationData.Id).FirstOrDefault();
            if (deletedEntry.Id != Guid.Empty)
            {
                db.OtherQualifications.Remove(deletedEntry);
                db.SaveChanges();
            }
            return(MapperFacade.MapperConfiguration.Map <OtherQualification, OtherQualificationDTO>(deletedEntry));
        }