public IHttpActionResult Delete(int Id, int userId, Boolean final)
        {
            var    re      = Request;
            var    headers = re.Headers;
            string token   = "";

            if (headers.Contains("APIKey"))
            {
                token = headers.GetValues("APIKey").First();
            }

            Validation validation = new Validation();
            bool       valid      = validation.CheckApiKey(token);

            if (valid)
            {
                if (final)
                {
                    try
                    {
                        using (incposdbEntities entity = new incposdbEntities())
                        {
                            medalAgent medalObj = entity.medalAgent.Find(Id);

                            entity.medalAgent.Remove(medalObj);
                            entity.SaveChanges();

                            return(Ok("medal is Deleted Successfully"));
                        }
                    }
                    catch
                    {
                        return(NotFound());
                    }
                }
                else
                {
                    try
                    {
                        using (incposdbEntities entity = new incposdbEntities())
                        {
                            medalAgent medalObj = entity.medalAgent.Find(Id);

                            medalObj.isActive     = 0;
                            medalObj.updateUserId = userId;
                            medalObj.updateDate   = DateTime.Now;
                            entity.SaveChanges();

                            return(Ok("Offer is Deleted Successfully"));
                        }
                    }
                    catch
                    {
                        return(NotFound());
                    }
                }
            }
            else
            {
                return(NotFound());
            }
        }
        public bool Save(string medalAgentObj)
        {
            var    re      = Request;
            var    headers = re.Headers;
            string token   = "";

            if (headers.Contains("APIKey"))
            {
                token = headers.GetValues("APIKey").First();
            }
            Validation validation = new Validation();
            bool       valid      = validation.CheckApiKey(token);

            if (valid)
            {
                medalAgentObj = medalAgentObj.Replace("\\", string.Empty);
                medalAgentObj = medalAgentObj.Trim('"');
                medalAgent Object = JsonConvert.DeserializeObject <medalAgent>(medalAgentObj, new JsonSerializerSettings {
                    DateParseHandling = DateParseHandling.None
                });
                try
                {
                    using (incposdbEntities entity = new incposdbEntities())
                    {
                        var medalEntity = entity.Set <medalAgent>();
                        if (Object.medalId == 0)
                        {
                            Object.createDate   = DateTime.Now;
                            Object.updateDate   = DateTime.Now;
                            Object.updateUserId = Object.createUserId;
                            medalEntity.Add(Object);
                            //  message = "medal Is Added Successfully";
                        }
                        else
                        {
                            var tmpmedal = entity.medalAgent.Where(p => p.medalId == Object.medalId).FirstOrDefault();

                            tmpmedal.id      = Object.id;
                            tmpmedal.medalId = Object.medalId;
                            tmpmedal.agentId = Object.agentId;

                            tmpmedal.notes = Object.notes;

                            tmpmedal.createDate   = Object.createDate;
                            tmpmedal.updateDate   = Object.updateDate;
                            tmpmedal.createUserId = Object.createUserId;
                            tmpmedal.updateUserId = Object.updateUserId;
                            tmpmedal.isActive     = Object.isActive;
                            tmpmedal.updateDate   = DateTime.Now;// server current date;
                            tmpmedal.updateUserId = Object.updateUserId;



                            //message = "medal Is Updated Successfully";
                        }
                        entity.SaveChanges();
                    }
                    return(true);
                }

                catch
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }