示例#1
0
        public HttpResponseMessage postPromo(promoPurConv point)
        {
            try
            {
                if (point.Id > 0)
                {
                }
                else
                {
                    point.Id = 0;
                }
                var rpoint = context.promoPurConvDb.Where(c => c.Id == point.Id).SingleOrDefault();
                if (rpoint != null)
                {
                    rpoint.point = point.point;
                    rpoint.rupee = point.rupee;

                    context.promoPurConvDb.Attach(rpoint);
                    context.Entry(rpoint).State = EntityState.Modified;
                    context.SaveChanges();
                }
                else
                {
                    context.promoPurConvDb.Add(point);
                    context.SaveChanges();
                    rpoint = point;
                }
                return(Request.CreateResponse(HttpStatusCode.OK, rpoint));
            }
            catch (Exception ex)
            {
                logger.Error("Error" + ex.Message);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Got Error"));;
            }
        }
示例#2
0
        public HttpResponseMessage GetPromo()
        {
            promoPurConv pointList = new promoPurConv();

            try
            {
                pointList = context.promoPurConvDb.FirstOrDefault();
                return(Request.CreateResponse(HttpStatusCode.OK, pointList));
            }
            catch (Exception ex)
            {
                logger.Error("Error in conversion " + ex.Message);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Got Error"));
            }
        }