public async Task <IHttpActionResult> DeleteUploadFilesSyS(Deleteuploadfile model)
        {
            try
            {
                string        result = "";
                returnAPiFlag abc    = new returnAPiFlag();

                string path = HttpContext.Current.Server.MapPath(model.filepath);
                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                    abc.status = model.filepath;
                    abc.flag   = true;
                }
                else
                {
                    abc.status = "File Not Available.";
                    abc.flag   = false;
                }
                return(Json(abc));
            }
            catch (Exception e)
            {
                returnAPiFlag abc = new returnAPiFlag();
                string        aaa = "File Delete Failed";
                abc.status = aaa;
                abc.flag   = false;
                return(Json(abc));
            }
        }
        public async Task <IHttpActionResult> SaveSuggestion()
        {
            WMC_WebApplicationEntities db = new WMC_WebApplicationEntities();

            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            var provider = await Request.Content.ReadAsMultipartAsync <InMemoryMultipartFormDataStreamProvider>(new InMemoryMultipartFormDataStreamProvider());

            //access form data
            NameValueCollection model = provider.FormData;
            //access files
            IList <HttpContent> files = provider.Files;


            returnAPiFlag        abcd = new returnAPiFlag();
            tbl_suggestionMaster abc  = new tbl_suggestionMaster();

            try
            {
                abc.pkd         = Convert.ToInt32(model["pkd"]);
                abc.title       = model["title"];
                abc.description = model["description"];
                abc.adddate     = DateTime.Now;
                abc.status      = 1;
            }
            catch
            {
                abcd.status = "Entered Required Field";
                abcd.flag   = true;
                return(Json(abcd));
            }
            try
            {
                string id;
                id = User.Identity.GetUserId();
                id = RequestContext.Principal.Identity.GetUserId();

                if (abc.pkd == 0)
                {
                    var httpRequest = HttpContext.Current.Request;
                    if (httpRequest.Files.Count > 0)
                    {
                        var docfiles = new List <string>();
                        for (int i = 0; i <= httpRequest.Files.Count - 1; i++)
                        {
                            WebFunction web        = new WebFunction();
                            var         postedFile = httpRequest.Files[i];
                            DateTime    date       = DateTime.Now;
                            string      dates      = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                            var         returnpath = "/UploadFiles/Suggestion/" + dates + postedFile.FileName;
                            var         filePath   = Path.Combine(HttpContext.Current.Server.MapPath("/UploadFiles/Suggestion/"), dates + postedFile.FileName);
                            postedFile.SaveAs(filePath);
                            abc.imagepath = returnpath;
                        }
                    }

                    abc.user_fkid = id;
                    db.tbl_suggestionMaster.Add(abc);
                    db.SaveChanges();
                    abcd.status = "Data Save Successfully";
                    abcd.flag   = true;
                }
                else
                {
                    var httpRequest = HttpContext.Current.Request;
                    if (httpRequest.Files.Count > 0)
                    {
                        var docfiles = new List <string>();
                        for (int i = 0; i <= httpRequest.Files.Count - 1; i++)
                        {
                            WebFunction web        = new WebFunction();
                            var         postedFile = httpRequest.Files[i];
                            DateTime    date       = DateTime.Now;
                            string      dates      = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                            var         returnpath = "/UploadFiles/Suggestion/" + dates + postedFile.FileName;
                            var         filePath   = Path.Combine(HttpContext.Current.Server.MapPath("/UploadFiles/Suggestion/"), dates + postedFile.FileName);
                            postedFile.SaveAs(filePath);
                            abc.imagepath = returnpath;
                        }
                    }
                    db.tbl_suggestionMaster.Attach(abc);
                    db.Entry(model).State = EntityState.Modified;
                    db.SaveChanges();
                    abcd.status = "Data updated Successfully";
                    abcd.flag   = true;
                }
                return(Json(abcd));
            }
            catch (Exception e)
            {
                abcd.status = "Data Save Failed";
                abcd.flag   = false;
                return(Json(abc));
            }
        }
        public async Task <IHttpActionResult> UploadFilesSyS(string ty = "")
        {
            try
            {
                string result            = "";
                List <returnAPiFlag> abc = new List <returnAPiFlag>();

                var filePath    = "";
                var httpRequest = HttpContext.Current.Request;
                if (httpRequest.Files.Count > 0)
                {
                    var docfiles = new List <string>();
                    for (int i = 0; i <= httpRequest.Files.Count - 1; i++)
                    {
                        var returnpath = "";
                        var postedFile = httpRequest.Files[i];
                        ty = Regex.Replace(ty, "^\"|\"$", "");
                        int      type  = Convert.ToInt32(ty);
                        DateTime date  = DateTime.Now;
                        string   dates = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                        if (type == 1)
                        {
                            returnpath = "/UploadFiles/Complaints/" + dates + postedFile.FileName;
                            filePath   = Path.Combine(HttpContext.Current.Server.MapPath("/UploadFiles/Complaints/"), dates + postedFile.FileName);
                        }
                        else if (type == 2)
                        {
                            returnpath = "/UploadFiles/Notice/" + dates + postedFile.FileName;
                            filePath   = Path.Combine(HttpContext.Current.Server.MapPath("/UploadFiles/Notice/"), dates + postedFile.FileName);
                        }
                        else if (type == 3)
                        {
                            returnpath = "/UploadFiles/Tourim/" + dates + postedFile.FileName;
                            filePath   = Path.Combine(HttpContext.Current.Server.MapPath("/UploadFiles/Notice/"), dates + postedFile.FileName);
                        }
                        if (File.Exists(filePath))
                        {
                            result = "File Already exist please change file name.....";
                            //abc.status = result;
                            //abc.flag = false;
                        }
                        else
                        {
                            postedFile.SaveAs(filePath);
                            docfiles.Add(filePath);
                            result = returnpath;
                            returnAPiFlag gh = new returnAPiFlag();
                            gh.status = result;
                            gh.flag   = true;
                            abc.Add(gh);
                        }
                    }
                    return(Json(abc));
                }
                else
                {
                    result = "File not select.";
                    returnAPiFlag gh = new returnAPiFlag();
                    gh.status = result;
                    gh.flag   = false;
                    abc.Add(gh);
                    return(Json(abc));
                }
            }
            catch (Exception e)
            {
                returnAPiFlag abc = new returnAPiFlag();
                string        aaa = "File Save Failed";
                abc.status = aaa;
                abc.flag   = false;
                return(Json(abc));
            }
        }
        public async Task <IHttpActionResult> EditUserProfile()
        {
            WMC_WebApplicationEntities db = new WMC_WebApplicationEntities();

            // Check if the request contains multipart/form-data.
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            var provider = await Request.Content.ReadAsMultipartAsync <InMemoryMultipartFormDataStreamProvider>(new InMemoryMultipartFormDataStreamProvider());

            //access form data
            NameValueCollection model = provider.FormData;
            //access files
            IList <HttpContent> files = provider.Files;


            returnAPiFlag   abcd = new returnAPiFlag();
            tbl_UserDetails abc  = new tbl_UserDetails();

            try
            {
                abc.pkid          = Convert.ToInt32(model["pkid"]);
                abc.FullName      = model["FullName"];
                abc.AddressLine1  = model["AddressLine1"];
                abc.AddressLine2  = model["AddressLine2"];
                abc.ContactNumber = model["ContactNumber"];
                abc.EmailId       = model["EmailId"];
                abc.ProdilePic    = model["ProdilePic"];
            }
            catch (Exception e)
            {
                abcd.status = e.Message;
                abcd.flag   = true;
                return(Json(abcd));
            }
            try
            {
                string id;
                id = User.Identity.GetUserId();
                id = RequestContext.Principal.Identity.GetUserId();

                if (abc.pkid == 0)
                {
                    abcd.status = "pkid is Required for Edit";
                    abcd.flag   = false;
                }
                else
                {
                    var editdata = db.tbl_UserDetails.Where(x => x.pkid == abc.pkid).FirstOrDefault();

                    var httpRequest = HttpContext.Current.Request;
                    if (httpRequest.Files.Count > 0)
                    {
                        var docfiles = new List <string>();
                        for (int i = 0; i <= httpRequest.Files.Count - 1; i++)
                        {
                            WebFunction web        = new WebFunction();
                            var         postedFile = httpRequest.Files[i];
                            DateTime    date       = DateTime.Now;
                            string      dates      = date.Day.ToString() + date.Month.ToString() + date.Year.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + date.ToString("tt");
                            var         returnpath = "/UploadFiles/Userspic/" + dates + postedFile.FileName;
                            var         filePath   = Path.Combine(HttpContext.Current.Server.MapPath("/UploadFiles/Userspic/"), dates + postedFile.FileName);
                            postedFile.SaveAs(filePath);
                            editdata.ProdilePic = returnpath;
                        }
                    }
                    editdata.FullName         = abc.FullName;
                    editdata.ContactNumber    = abc.ContactNumber;
                    editdata.AddressLine1     = abc.AddressLine1;
                    editdata.AddressLine2     = abc.AddressLine2;
                    editdata.EmailId          = abc.EmailId;
                    editdata.LastModifiedDate = DateTime.Now;
                    db.tbl_UserDetails.Attach(editdata);
                    db.Entry(editdata).State = EntityState.Modified;
                    db.SaveChanges();
                    abcd.status = "Data updated Successfully";
                    abcd.flag   = true;
                }
                return(Json(abcd));
            }
            catch (Exception e)
            {
                abcd.status = e.Message;
                abcd.flag   = false;
                return(Json(abc));
            }
        }