Esempio n. 1
0
        public HttpResponseMessage UploadImage()
        {
            string ImageName = null;
            int    EmpId;
            var    httpRequest = HttpContext.Current.Request;
            var    PostedFile  = httpRequest.Files["Image"];

            ImageName = new string(Path.GetFileNameWithoutExtension(PostedFile.FileName).Take(10).ToArray()).Replace(" ", "_");
            ImageName = ImageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(PostedFile.FileName);
            var filePath = HttpContext.Current.Server.MapPath("~/Image/" + ImageName);

            PostedFile.SaveAs(filePath);
            EmpId = Convert.ToInt32(httpRequest["EmployeeId"]);

            using (OVODEntities entities = new OVODEntities())
            {
                var entity = entities.ANG_EMPLOYEE.FirstOrDefault(e => e.id == EmpId);
                if (entity == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee id: " + EmpId.ToString() + " not found to update."));
                }
                else
                {
                    entity.PhotoPath = ImageName;
                    entities.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.Created));
                }
            }
        }
        // PUT api/<controller>/5
        public HttpResponseMessage Put_PaymentDetails(int id, PaymentDetail PaymentDetails)
        {
            try
            {
                if (id != PaymentDetails.PMId)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ""));
                }

                using (OVODEntities entities = new OVODEntities())
                {
                    var entity = entities.PaymentDetails.FirstOrDefault(e => e.PMId == PaymentDetails.PMId);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Paymentdetails id: " + PaymentDetails.PMId.ToString() + " not found to update."));
                    }
                    else
                    {
                        entity.CardOwnerName  = PaymentDetails.CardOwnerName;
                        entity.CardNumber     = PaymentDetails.CardNumber;
                        entity.ExpirationDate = PaymentDetails.ExpirationDate;
                        entity.CVV            = PaymentDetails.CVV;
                        entities.SaveChanges();
                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Esempio n. 3
0
 public Participant UpdateOutput(Participant model)
 {
     using (OVODEntities db = new OVODEntities())
     {
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
         return(model);
     }
 }
Esempio n. 4
0
 public Participant Insert(Participant model)
 {
     using (OVODEntities db = new OVODEntities())
     {
         db.Participants.Add(model);
         db.SaveChanges();
         return(model);
     }
 }
 public IHttpActionResult PostHD_HRPAYADJ(HD_HRPAYADJ DT_HRPAYADJ)
 {
     try
     {
         if (DT_HRPAYADJ.PA_ID == 0)
         {
             DB.HD_HRPAYADJ.Add(DT_HRPAYADJ);
         }
         else
         {
             //DB.Entry(DT_HRPAYADJ).State = EntityState.Modified;
             DB.Set <HD_HRPAYADJ>().AddOrUpdate(DT_HRPAYADJ);
         }
         foreach (var item in DT_HRPAYADJ.DT_HRPAYADJ)
         {
             if (item.PAD_ID == 0)
             {
                 DB.DT_HRPAYADJ.Add(item);
             }
             else
             {
                 DB.Entry(item).State = EntityState.Modified;
             }
         }
         foreach (var id in DT_HRPAYADJ.DeletedPayAdjdIds.Split(',').Where(x => x != ""))
         {
             DT_HRPAYADJ x = DB.DT_HRPAYADJ.Find(Convert.ToInt64(id));
             DB.DT_HRPAYADJ.Remove(x);
         }
         DB.SaveChanges();
         //return CreatedAtRoute("DefaultApi", new { id = DT_HRPAYADJ.PA_ID }, DT_HRPAYADJ);
         return(Ok());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 6
0
 public HttpResponseMessage TTList([FromBody] TTMAST tTMAST)
 {
     try
     {
         using (OVODEntities db = new OVODEntities())
         {
             if (tTMAST.TT_ID == 0)
             {
                 db.TTMASTs.Add(tTMAST);
                 db.SaveChanges();
             }
             else
             {
                 db.Entry(tTMAST).State = EntityState.Modified;
                 db.SaveChanges();
             }
             return(Request.CreateResponse(HttpStatusCode.Created));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
 // POST api/<controller>
 public HttpResponseMessage Post([FromBody] PaymentDetail PaymentDetails)
 {
     try
     {
         using (OVODEntities entities = new OVODEntities())
         {
             //eMPLOYEE.PhotoPath = imageName;
             entities.PaymentDetails.Add(PaymentDetails);
             entities.SaveChanges();
         }
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Esempio n. 8
0
        //public HttpResponseMessage PostAng_Employees([FromBody]ANG_EMPLOYEE employee) {
        //    try
        //    {
        //        using (OVODEntities entities = new OVODEntities()) {
        //            entities.ANG_EMPLOYEE.Add(employee);
        //            entities.SaveChanges();
        //            var message = Request.CreateResponse(HttpStatusCode.Created, employee);
        //            message.Headers.Location = new Uri(Request.RequestUri + employee.id.ToString());
        //            return message;
        //        }
        //    }
        //    catch (Exception ex){
        //        return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
        //    }
        //}

        public HttpResponseMessage PutAng_Employees([FromBody] ANG_EMPLOYEE employee)
        {
            try
            {
                string imageName   = null;
                var    httpRequest = System.Web.HttpContext.Current.Request;
                var    postedFile  = httpRequest.Files["Image"];
                imageName = new string(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "-");
                imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile.FileName);
                var filePath = HttpContext.Current.Server.MapPath("~/Image/" + imageName);
                postedFile.SaveAs(imageName);

                using (OVODEntities entities = new OVODEntities())
                {
                    var entity = entities.ANG_EMPLOYEE.FirstOrDefault(e => e.id == employee.id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee id: " + employee.id.ToString() + " not found to update."));
                    }
                    else
                    {
                        entity.name        = employee.name;
                        entity.isActive    = employee.isActive;
                        entity.password    = employee.password;
                        entity.PhoneNumber = employee.PhoneNumber;
                        //entity.PhotoPath = employee.PhotoPath;
                        entity.PhotoPath         = imageName;
                        entity.gender            = employee.gender;
                        entity.email             = employee.email;
                        entity.department        = employee.department;
                        entity.dateofBirth       = employee.dateofBirth;
                        entity.ContactPreference = employee.ContactPreference;
                        entities.SaveChanges();
                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Esempio n. 9
0
        public HttpResponseMessage Post([FromBody] ANG_EMPLOYEE eMPLOYEE)
        {
            try
            {
                //string imageName = null;
                //var httpRequest = System.Web.HttpContext.Current.Request;
                //var postedFile = httpRequest.Files["Image"];
                //imageName = new string(Path.GetFileNameWithoutExtension(postedFile.FileName).Take(10).ToArray()).Replace(" ", "_");
                //imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(postedFile.FileName);
                //postedFile.SaveAs(imageName);

                //if (eMPLOYEE.Image != null)
                //{


                //    //eMPLOYEE.Image.SaveAs(Path.Combine(filePath));

                //}
                using (OVODEntities entities = new OVODEntities())
                {
                    //eMPLOYEE.PhotoPath = imageName;
                    entities.ANG_EMPLOYEE.Add(eMPLOYEE);
                    entities.SaveChanges();
                }
                //if (eMPLOYEE.Image != null)
                //{
                //    imageName = Path.GetFileNameWithoutExtension(eMPLOYEE.Image.FileName);
                //    string imageExtn = Path.GetExtension(eMPLOYEE.Image.FileName);
                //    imageName = imageName + DateTime.Now.ToString("yymmssfff") + imageExtn;
                //    var filePath = HttpContext.Current.Server.MapPath("~/Image/" + imageName);
                //    eMPLOYEE.Image.SaveAs(Path.Combine(filePath));
                //}
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Esempio n. 10
0
 public HttpResponseMessage Delete(int id)
 {
     try
     {
         using (OVODEntities entities = new OVODEntities())
         {
             var entity = entities.ANG_EMPLOYEE.FirstOrDefault(e => e.id == id);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee id: " + id.ToString() + " not found to delete."));
             }
             else
             {
                 entities.ANG_EMPLOYEE.Remove(entity);
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK, entity));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }