diff --git a/Models/ProfilePicture.cs b/Models/ProfilePicture.cs new file mode 100644 index 0000000..e664b66 --- /dev/null +++ b/Models/ProfilePicture.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Web; +using System.Web.UI; + +namespace ERPSystemTimologio.Models +{ + public class ProfilePicture + { + public string ErrorMessage { get; set; } + public decimal Filesize { get; set; } + public string Upload(HttpPostedFileBase file, string username) + { + try + { + var supportFileType = new[] { "jpg", "jpeg", "png", "gif" }; + var getFileExtension = Path.GetExtension(file.FileName).Substring(1); + + if (!supportFileType.Contains(getFileExtension)) + { + ErrorMessage = "File must be jpg/jpeg/png/gif format"; + return ErrorMessage; + } + else if (file.ContentLength > (Filesize * 1024)) + { + ErrorMessage = "File size must be less than " + Filesize + "KB"; + return ErrorMessage; + } + + string _path = Path.Combine(HttpContext.Current.Server.MapPath("~/Content/images/avatar"), username + "." + getFileExtension); + file.SaveAs(_path); + + return null; + } + catch (Exception) + { + ErrorMessage = "Upload Container Should Not Be Empty"; + return ErrorMessage; + } + } + } +} \ No newline at end of file diff --git a/Views/Dashboard/ProfilePicture.cshtml b/Views/Dashboard/ProfilePicture.cshtml new file mode 100644 index 0000000..73ac1b7 --- /dev/null +++ b/Views/Dashboard/ProfilePicture.cshtml @@ -0,0 +1,40 @@ + +@{ + ViewBag.Title = "ProfilePicture"; + + ERPSystemTimologio.EF.User sessionUser = null; + + if (Session["user"] != null) + { + sessionUser = (ERPSystemTimologio.EF.User)Session["user"]; + } +} + +
\ No newline at end of file