public HttpResponseMessage put(int id, WORKEXPERIENCE workexperience)
        {
            try
            {
                using (WorkExperienceEntities entities = new WorkExperienceEntities())
                {
                    var entity = entities.WORKEXPERIENCE.FirstOrDefault(e => e.WorkExperienceId == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "WorkExperience doesnt exist"));
                    }
                    else
                    {
                        entity.WorkExperienceId = workexperience.WorkExperienceId;
                        entity.EmployeeId       = workexperience.EmployeeId;
                        entity.DocumentId       = workexperience.DocumentId;
                        entity.CompanyName      = workexperience.CompanyName;
                        entity.JobTitle         = workexperience.JobTitle;
                        entity.StartDate        = workexperience.StartDate;
                        entity.Enddate          = workexperience.Enddate;
                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
 public HttpResponseMessage post([FromBody] WORKEXPERIENCE workexperience)
 {
     try
     {
         using (WorkExperienceEntities entities = new WorkExperienceEntities())
         {
             entities.WORKEXPERIENCE.Add(workexperience);
             entities.SaveChanges();
             HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, workexperience);
             message.Headers.Location = new Uri(Request.RequestUri + workexperience.WorkExperienceId.ToString());
             return(message);
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Beispiel #3
0
        public ActionResult AddOrUpdateExperience(WorkExperienceVM workexperience)
        {
            string msg = string.Empty;

            if (workexperience != null)
            {
                AutoMapper.Mapper.Reset();
                Mapper.Initialize(cfg => cfg.CreateMap <WorkExperienceVM, WORKEXPERIENCE>());
                WORKEXPERIENCE workExperienceEntity = AutoMapper.Mapper.Map <WORKEXPERIENCE>(workexperience);
                int            idPer = (int)Session["IdSelected"];

                msg = resumeRepo.AddOrUpdateExperience(workExperienceEntity, idPer);
            }
            else
            {
                msg = "Please re try the operation";
            }
            return(Json(new { data = msg }, JsonRequestBehavior.AllowGet));
        }
        public HttpResponseMessage get(int id)
        {
            try
            {
                using (WorkExperienceEntities entities = new WorkExperienceEntities())
                {
                    WORKEXPERIENCE workexperience = entities.WORKEXPERIENCE.FirstOrDefault(e => e.WorkExperienceId == id);
                    if (workexperience != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, workexperience));
                    }

                    else
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No entity with id " + id + "found!"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
        public string AddOrUpdateExperience(WORKEXPERIENCE workExperience, int idPer)
        {
            string msg = string.Empty;

            USER userEntity = context.USERs.Find(idPer);

            if (userEntity != null)
            {
                if (workExperience.ID > 0)
                {
                    context.Entry(workExperience).State = EntityState.Modified;
                    context.SaveChanges();

                    msg = "Education entity has been updated successfully";
                }
                else
                {
                    userEntity.WORKEXPERIENCEs.Add(workExperience);
                    context.SaveChanges();
                }
            }
            return(msg);
        }