/// <summary> /// Set Sod User Dp /// </summary> /// <param name="model"></param> /// <param name="EmpCode"></param> /// <returns></returns> public Int64 UserSetDp(SodUserProfileDp model, string EmpCode) { Int64 ID = 0; var dp = model.ImageFile; byte[] dpimage = null; if (dp != null) { BinaryReader reader = new BinaryReader(dp.InputStream); dpimage = reader.ReadBytes(dp.ContentLength); var dataexists = _context.SodUserProfileDp.Where(x => x.EmployeeCode == EmpCode).FirstOrDefault(); if (dataexists != null) { dataexists.ImageName = DateTime.Now.Ticks + model.ImageFile.FileName; dataexists.DpImage = dpimage; ID = dataexists.dpid; _context.SaveChanges(); } else { model.ImageName = DateTime.Now.Ticks + model.ImageFile.FileName; model.DpImage = dpimage; model.EmployeeCode = EmpCode; _context.SodUserProfileDp.Add(model); _context.SaveChanges(); ID = model.dpid; } //_context.SaveChanges(); } return(ID); }
//Sod User Profile Dp public JsonResult SetDp(SodUserProfileDp model) { Int64 id = _changerequest.UserSetDp(model, Session["EmpCode"].ToString()); return(Json(id != 0 ? "Profile picture uploaded!!" : "Failed to uploaded!!", JsonRequestBehavior.AllowGet)); }