public CMSResult Update(UploadPracticepapers uploadNewPracticepapers) { CMSResult result = new CMSResult(); var isExists = _repository.Project <UploadPracticepapers, bool>(uploadPracticepapers => ( from p in uploadPracticepapers where p.FileName == uploadNewPracticepapers.FileName && p.UploadPracticepapersId != uploadNewPracticepapers.UploadPracticepapersId select p ).Any()); if (isExists) { result.Results.Add(new Result { IsSuccessful = false, Message = string.Format("Practicepapers file '{0}' already exists!", uploadNewPracticepapers.FileName) }); } else { var Practicepapers = _repository.Load <UploadPracticepapers>(x => x.UploadPracticepapersId == uploadNewPracticepapers.UploadPracticepapersId); Practicepapers.ClassName = uploadNewPracticepapers.ClassName; Practicepapers.Title = uploadNewPracticepapers.Title; Practicepapers.FileName = uploadNewPracticepapers.FileName; Practicepapers.LogoName = uploadNewPracticepapers.LogoName; Practicepapers.BoardName = uploadNewPracticepapers.BoardName; Practicepapers.SubjectName = uploadNewPracticepapers.SubjectName; Practicepapers.UploadDate = uploadNewPracticepapers.UploadDate; Practicepapers.IsVisible = uploadNewPracticepapers.IsVisible; _repository.Update(Practicepapers); result.Results.Add(new Result { IsSuccessful = true, Message = string.Format("Practicepapers updated successfully!") }); } return(result); }
public CMSResult Save(UploadPracticepapers newUploadPracticepapers) { CMSResult result = new CMSResult(); var isExists = _repository.Project <UploadPracticepapers, bool>(uploadPracticepapers => ( from p in uploadPracticepapers where p.FileName == newUploadPracticepapers.FileName select p ).Any()); if (isExists) { result.Results.Add(new Result { IsSuccessful = false, Message = string.Format("Practicepapers file '{0}' already exists!", newUploadPracticepapers.FileName) }); } else { _repository.Add(newUploadPracticepapers); result.Results.Add(new Result { IsSuccessful = true, Message = string.Format("Practicepapers file '{0}' added successfully!", newUploadPracticepapers.FileName) }); } return(result); }