public ActionResult Create(string Title, string TitleInEng, string Description, HttpPostedFileBase scholarshipImage) { //Title ScholarshipDTO model = new ScholarshipDTO() { Title = Title, TitleInEnglish = TitleInEng, Description = Description, }; if (!ModelState.IsValid) { return(View()); } if (scholarshipImage != null) { var Extension = scholarshipImage.FileName.Substring(scholarshipImage.FileName.LastIndexOf('.')).ToLower(); var LowerExtension = Extension.ToLower(); string FileNameImage = "scholarshipImage-" + Guid.NewGuid().ToString() + LowerExtension; model.ImagPath = FileNameImage; string path = Path.Combine(Server.MapPath("~/UploadedImages/scholarship"), FileNameImage.Replace(" ", "_")); scholarshipImage.SaveAs(path); } bool checkSuccess = _manager.Create(model); if (checkSuccess) { return(RedirectToAction("Index")); } return(View()); }
public ScholarshipDTO GetById(int id) { try { var Scholarship = _repository.Get(id); ScholarshipDTO query = Scholarship != null ? new ScholarshipDTO() { Id = Scholarship.Id, IPAddress = Scholarship.IPAddress, ImagPath = Scholarship.ImagPath, Description = Scholarship.Description, AddUserId = Scholarship.AddUserId, Title = Scholarship.Title, AddedDate = Scholarship.AddedDate, ModifiedDate = Scholarship.ModifiedDate, ModifyUserId = Scholarship.ModifyUserId, } : null; return(query); } catch (Exception ex) { throw ex; } }
public bool Create(ScholarshipDTO _Scholarship) { try { scholarship Scholarship = new scholarship() { Title = _Scholarship.Title, AddUserId = _Scholarship.AddUserId, Description = _Scholarship.Description, ImagPath = _Scholarship.ImagPath, IPAddress = _Scholarship.IPAddress, TitleInEnglish = _Scholarship.TitleInEnglish, }; _repository.Add(Scholarship); return(_unitOfWork.SaveChanges()); } catch (Exception ex) { throw ex; } }
public bool Update(ScholarshipDTO item) { throw new NotImplementedException(); }