Ejemplo n.º 1
0
 public ActionResult EditUserDetails(tbl_UserDetailsss model, HttpPostedFileBase pic)
 {
     try
     {
         tbl_UserDetails abc = _user.Get(model.pkid);
         abc.FullName         = model.FullName;
         abc.ContactNumber    = model.ContactNumber;
         abc.AddressLine1     = model.AddressLine1;
         abc.RoleName         = model.RoleName;
         abc.EmailId          = model.EmailId;
         abc.LastModifiedDate = DateTime.Now;
         if (pic != null)
         {
             string path = System.Web.HttpContext.Current.Server.MapPath(model.ProdilePic);
             if (System.IO.File.Exists(path))
             {
                 System.IO.File.Delete(path);
             }
             WebFunction web = new WebFunction();
             model.ProdilePic = web.Storefile(pic, 4);
         }
         _user.Update(abc);
         return(RedirectToAction("Register", "Account"));
     }
     catch (Exception e)
     {
         Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
         ViewBag.Exception = e.Message;
         return(View());
     }
 }
Ejemplo n.º 2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            tbl_UserDetails tbl_UserDetails = await db.tbl_UserDetails.FindAsync(id);

            db.tbl_UserDetails.Remove(tbl_UserDetails);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Edit([Bind(Include = "UserID,UserCode,UserType,UserFirstName,UserLastName,IsActive,CreatedOn,UpdatedDate,CreatedBy,UserContactNumber,UserEmailID,Documents,UserRoleID,Password")] tbl_UserDetails tbl_UserDetails)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tbl_UserDetails).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(tbl_UserDetails));
        }
Ejemplo n.º 4
0
        // GET: tbl_UserDetails/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_UserDetails tbl_UserDetails = await db.tbl_UserDetails.FindAsync(id);

            if (tbl_UserDetails == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_UserDetails));
        }
Ejemplo n.º 5
0
        public ActionResult SaveCustomer()
        {
            string userid = "";

            try
            {
                userid = TempData["id"].ToString();
                string ro    = TempData["role"].ToString();
                string Uname = null;
                try { Uname = TempData["username"].ToString(); }
                catch { }
                string email = null;
                try { email = TempData["ema"].ToString(); }
                catch { }
                string pas    = TempData["passwo"].ToString();
                string funame = null;
                try { funame = TempData["fname"].ToString(); }
                catch { }
                string mobino = null;
                try { mobino = TempData["mobi"].ToString(); }
                catch { }

                tbl_UserDetails abc = new tbl_UserDetails();
                abc.User_fkid        = userid;
                abc.UserName         = Uname;
                abc.RoleName         = ro;
                abc.EmailId          = email;
                abc.FullName         = funame;
                abc.ContactNumber    = mobino;
                abc.RegisteredDate   = DateTime.Now;
                abc.LastModifiedDate = DateTime.Now;
                _user.Add(abc);
                return(RedirectToAction("Register", "Account"));
            }
            catch (Exception e)
            {
                Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
                return(RedirectToAction("Register", "Account", new { Exceptionmsg = e.Message, id = userid }));
            }
        }
        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));
            }
        }