public bool UpdateDictionary(int dictionaryId) { var dictionary = DictionariesRepository.GetById(dictionaryId); if (dictionary.ParentDictionaryId == null) { return(false); } var currentTranslations = TranslationsRepository.GetTranslationsForDictionary(dictionaryId).ToList(); var parentTranslations = TranslationsRepository.GetTranslationsForDictionary(dictionary.ParentDictionaryId.Value).ToList(); var toAdd = parentTranslations.Except(currentTranslations).ToList(); toAdd.ForEach(trans => { var translation = new Translation { DictionaryId = dictionaryId, FirstLangWord = trans.FirstLangWord, SecondLangWord = trans.SecondLangWord }; TranslationsRepository.Insert(translation); }); return(TranslationsRepository.Save());; }
public int CopyDictionary(int dictionaryId, int userId) { var translations = TranslationsRepository.GetTranslationsForDictionary(dictionaryId).ToList(); var dictionary = DictionariesRepository.GetById(dictionaryId); Context.Entry(dictionary).State = EntityState.Detached; dictionary.Id = 0; dictionary.UserId = userId; dictionary.ParentDictionaryId = dictionaryId; dictionary.User = null; dictionary.Date = DateTime.Today; dictionary.IsPublic = false; DictionariesRepository.Insert(dictionary); DictionariesRepository.Save(); translations.ForEach(translation => { Context.Entry(translation).State = EntityState.Detached; translation.Id = 0; translation.DictionaryId = dictionary.Id; translation.Dictionary = null; }); var check = TranslationsRepository.Insert(translations) && TranslationsRepository.Save(); return(check ? dictionary.Id : -1); }
public ActionResult Get(int id) { var dictionary = DictionariesRepository.GetById(id); if (dictionary.IsPublic) { AccessGuardian(Roles.AccessUser); } else { AccessGuardian(Roles.AccessUser, dictionary.UserId); } return(JsonHelper.Success(DictionariesRepository.GetById(id))); }
public bool Delete(int dictionaryId) { TranslationsRepository.DeleteByDictionaryId(dictionaryId); TranslationsRepository.Save(); GameSessionTranslationsRepository.DeleteByDictionaryId(dictionaryId); GameSessionTranslationsRepository.Save(); GameSessionsRepository.DeleteByDictionaryId(dictionaryId); GameSessionsRepository.Save(); DictionariesRepository.Delete(dictionaryId); DictionariesRepository.Save(); return(true); }
public FileResult Export(int dictionaryId) { var dictionary = DictionariesRepository.GetById(dictionaryId); if (dictionary.IsPublic) { AccessGuardian(Roles.AccessUser); } else { AccessGuardian(Roles.AccessUser, dictionary.UserId); } var stream = DataExchangeService.ExportDictionary(dictionaryId); /* * var result = new HttpResponseMessage(HttpStatusCode.OK) * { * Content = new ByteArrayContent(stream.ToArray()) * }; * result.Content.Headers.ContentDisposition = * new ContentDispositionHeaderValue("attachment") * { * FileName = $"slownik_{dictionaryId}_{DateTime.Today}.csv" * }; * result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); * * return result;*/ Context.Response.ContentType = "application/octet-stream"; var result = new FileContentResult(stream.ToArray(), "application/octet-stream") { FileDownloadName = $"eksport_slownik_{dictionaryId}_{DateTime.Now:dd-MM-yyyy}.csv" }; return(result); }
protected void btnSend_Click(object sender, EventArgs e) { var N = new NoficicationsRepository(); var fuURLFileName = ""; if (fuURL.HasFile) { fuURLFileName = fuURL.FileName.ToAZ09Dash(true, true); var path = string.Format("{0}//Notifications//", Utility.GetUploadFolder()); fuURL.SaveAs(string.Format("{0}{1}", path, fuURLFileName)); } var fuURLFileName2 = ""; if (fuURL2.HasFile) { fuURLFileName2 = fuURL2.FileName.ToAZ09Dash(true, true); var path = string.Format("{0}//Notifications//", Utility.GetUploadFolder()); fuURL2.SaveAs(string.Format("{0}{1}", path, fuURLFileName2)); } var fuURLNoteFile = ""; if (fuURLNote.HasFile) { fuURLNoteFile = fuURLNote.FileName.ToAZ09Dash(true, true); var path = string.Format("{0}//Notifications//", Utility.GetUploadFolder()); fuURLNote.SaveAs(string.Format("{0}{1}", path, fuURLNoteFile)); } var fuURLNoteFile1 = ""; if (fuURLNote1.HasFile) { fuURLNoteFile1 = fuURLNote1.FileName.ToAZ09Dash(true, true); var path = string.Format("{0}//Notifications//", Utility.GetUploadFolder()); fuURLNote1.SaveAs(string.Format("{0}{1}", path, fuURLNoteFile1)); } var fuURLNoteFile2 = ""; if (fuURLNote2.HasFile) { fuURLNoteFile2 = fuURLNote2.FileName.ToAZ09Dash(true, true); var path = string.Format("{0}//Notifications//", Utility.GetUploadFolder()); fuURLNote2.SaveAs(string.Format("{0}{1}", path, fuURLNoteFile2)); } var NotifType = new DictionariesRepository().ListDictionary(1, 9).FirstOrDefault(w => w.CodeVal == Convert.ToInt32(hfNotifyType.Value)).DictionaryID; /* * N.SP_Notifications(0, * NotificationTypeID: NotifType, * OrgName : txtOrgName.Text, * Address: txtAddress.Text, * Mobile: txtMobile.Text, * Email: txtEmail.Text, * WebPage: txtWebPage.Text, * URL: fuURLFileName, * MissionDesc: txtMissionDesc.Text, * Contact: txtContact.Text, * Desc1: txtDesc1.Text, * Desc2: txtDesc2.Text, * Number: txtNumber.Text, * Donors: txtDonors.Text, * Term: txtTerms.Text, * Proportions: txtProportions.Text, * RegFileURL: fuURLNoteFile * ); */ //if (!N.IsError) { var NObj = new Core.Notifications(); switch (hfNotifyType.Value) { case "2": NObj.NotificationTypeID = NotifType; NObj.OrgName = txtOrgName.Text; NObj.Address = txtAddress.Text; NObj.Mobile = txtMobile.Text; NObj.Email = txtEmail.Text; NObj.WebPage = txtWebPage.Text; NObj.URL = fuURLFileName; NObj.MissionDesc = txtMissionDesc.Text; NObj.Contact = txtContact.Text; NObj.Desc1 = txtDesc1.Text; NObj.Desc2 = txtDesc2.Text; NObj.Number = txtNumber.Text; NObj.Donors = txtDonors.Text; NObj.Term = txtTerms.Text; NObj.Proportions = txtProportions.Text; NObj.RegFileURL = fuURLNoteFile; Session["IsSent"] = MakeNotification(NObj); break; case "3": NObj.NotificationTypeID = NotifType; NObj.OrgName = txtOrgName1.Text; NObj.Address = txtAddress1.Text; NObj.Mobile = txtMobile1.Text; NObj.Email = txtEmail1.Text; NObj.WebPage = txtWebPage1.Text; //NObj.URL = fuURLFileName2; NObj.MissionDesc = txtMissionDesc1.Text; NObj.Contact = txtContact1.Text; NObj.ProjectTitle = txtProjectTitle.Text; //NObj.Donors = txtDonors1.Text; NObj.ProjectStatus = txtProjectStatus.Text; //NObj.Term = txtTerms.Text; NObj.Donors = txtDonors1.Text; NObj.Term = txtProjectGoal1.Text; NObj.ProjectResults = txtProjectResults1.Text; NObj.ProjectFDate = DateTime.Parse(txtProjectFDate.Text); NObj.ProjectLDate = DateTime.Parse(txtProjectLDate.Text); //NObj.Proportions = txtProportions.Text; NObj.RegFileURL = fuURLNoteFile1; Session["IsSent"] = MakeNotification(NObj); break; case "4": NObj.NotificationTypeID = NotifType; NObj.OrgName = txtOrgName2.Text; NObj.Address = txtAddress2.Text; NObj.Mobile = txtMobile2.Text; NObj.Email = txtEmail2.Text; NObj.WebPage = txtWebPage2.Text; NObj.URL = fuURLFileName2; NObj.MissionDesc = txtMission2.Text; NObj.IsActualProjects = bool.Parse(txtIsActive2.Text); // es rogor unda iyos?? NObj.ProjectTitle = txtProjectTitle2.Text; NObj.ProjectStatus = txtProjectStatus2.Text; NObj.Donors = txtDonorContacts.Text; NObj.Term = txtProjectGoal2.Text; NObj.ProjectResults = txtProjectResults1.Text; NObj.ProjectFDate = DateTime.Parse(txtProjectFDate.Text); NObj.ProjectLDate = DateTime.Parse(txtProjectLDate.Text); NObj.FinanceInfo = txtFinanceInfo.Text; NObj.PartnerInfo = txtPartnerInfo.Text; NObj.DepartPlan = txtDepart.Text; NObj.RegFileURL = fuURLNoteFile2; Session["IsSent"] = MakeNotification(NObj); break; } //NObj.Desc1 = txtDesc1.Text; //NObj.Desc2 = txtDesc2.Text; //NObj.Number = txtNumber.Text; Response.Redirect(Request.Url.OriginalString); } }
protected void btnSend_Click(object sender, EventArgs e) { var N = new NoficicationsRepository(); var fuURLFileName = ""; if (fuURL.HasFile) { fuURLFileName = fuURL.FileName.ToAZ09Dash(true, true); var path = string.Format("{0}//Notifications//", Utility.GetUploadFolder()); fuURL.SaveAs(string.Format("{0}{1}", path, fuURLFileName)); } var NotifType = new DictionariesRepository().ListDictionary(1, 9).FirstOrDefault(w => w.CodeVal == 1).DictionaryID; var BDate = new DateTime(Convert.ToInt32(ddBYear.SelectedValue), Convert.ToInt32(ddBMonth.SelectedValue), Convert.ToInt32(ddBDay.SelectedValue)); var EnteryDate = string.IsNullOrEmpty(txtFDate.Text) ? DateTime.Now : DateTime.Parse(txtFDate.Text); var LeaveDate = string.IsNullOrEmpty(txtLDate.Text) ? DateTime.Now : DateTime.Parse(txtLDate.Text); /* * N.SP_Notifications(0, * NotificationTypeID: NotifType, * URL: fuURLFileName, * FName: txtFName.Text, * LName: txtLName.Text, * Address: txtAddress.Text, * Mobile: txtMobile.Text, * Fax: txtFax.Text, * Email: txtEmail.Text, * PassportN: txtPassportN.Text, * Nationality: txtNationality.Text, * BDate: BDate, * Gender: bool.Parse(ddGender.SelectedValue), * EnteryDate: EnteryDate, * LeaveDate: LeaveDate, * Organisator: ddOrganisator.SelectedValue, * TransportType: ddTransportType.SelectedValue, * Destination: txtDestination.Text, * HostName: txtHostName.Text, * HostContact: txtHostContact.Text, * EmFName : txtFName1.Text, * EmLName: txtLName1.Text, * EmAddress: txtAddress1.Text, * EmMobile: txtMobile1.Text, * VisitorStatus : txtProjectStatus.Text, * ProjectTitle: txtProjectName.Text, * ProjectNote :txtProjectGoal.Text, * ProjectFDate: DateTime.Parse(txtProjectFDate.Text), * ProjectLDate:DateTime.Parse(txtProjectLDate.Text), * Partner: txtLocalPartner.Text, * IsSent : bool.Parse(ddIsSent.SelectedValue), * Note: txtNote.Text); * if (!N.IsError) * { */ var NotifyObject = new Core.Notifications { NotificationTypeID = NotifType, URL = fuURLFileName, FName = txtFName.Text, LName = txtLName.Text, Address = txtAddress.Text, Mobile = txtMobile.Text, Fax = txtFax.Text, Email = txtEmail.Text, PassportN = txtPassportN.Text, Nationality = txtNationality.Text, BDate = BDate, //Sex = bool.Parse(ddGender.SelectedValue), EnteryDate = EnteryDate, LeaveDate = LeaveDate, Organisator = txtVisitOrganisedBy.Text, TransportType = ddTransportType.SelectedValue, Destination = txtDestination.Text, HostName = txtHostName.Text, HostContact = txtHostContact.Text, EmFName = txtFName1.Text, EmLName = txtLName1.Text, EmAddress = txtAddress1.Text, EmMobile = txtMobile1.Text, VisitorStatus = txtProjectStatus.Text, ProjectTitle = txtProjectName.Text, ProjectNote = txtProjectGoal.Text, ProjectFDate = DateTime.Parse(txtProjectFDate.Text), ProjectLDate = DateTime.Parse(txtProjectLDate.Text), Partner = txtLocalPartner.Text, //IsSent = bool.Parse(ddIsSent.SelectedValue), Note = txtNote.Text }; var M = new Core.Tools.Mail(); var ms = new MemoryStream(); var ListAtt = new List <Attachment>(); var rpt = new rptNotification(NotifyObject); var FileName = string.Format("Notification_{0:yyyy-MM-dd}_{1}.pdf", DateTime.Now, Guid.NewGuid().ToString().Substring(1, 6)); rpt.ExportToPdf(ms); ms.Seek(0, System.IO.SeekOrigin.Begin); var attach = new Attachment(ms, FileName, "application/pdf"); ListAtt.Add(attach); M.Send("*****@*****.**", "*****@*****.**", "სანოტიფიკაციო ფორმა", "ინფორმაცია საიტიდან", AttachmentsList: ListAtt); ms.Close(); Session["IsSent"] = true; Response.Redirect(Request.Url.OriginalString); //} }
public ActionResult Delete(int id) { AccessGuardian(new AccessRole(Roles.AccessUser, DictionariesRepository.GetById(id).UserId)); return(JsonHelper.Response(DictionariesService.Delete(id))); }
public ActionResult GetForUser(int userId) { AccessGuardian(new AccessRole(Roles.AccessUser, userId)); return(JsonHelper.Success(DictionariesRepository.GetForUser(userId))); }
public ActionResult GetAllPublic() { AccessGuardian(Roles.AccessUser); return(JsonHelper.Success(DictionariesRepository.GetAllPublic())); }
public ActionResult Get() { AccessGuardian(new AccessRole(Roles.AccessUser)); return(JsonHelper.Success(DictionariesRepository.GetAll().ToList())); }
public int InsertOrUpdate(DictionaryDTO dictionaryVo) { using (var transaction = Context.Database.BeginTransaction()) { try { var dictionary = Mapper.Map <Dictionary>(dictionaryVo); if (dictionary.Id > 0) { Context.Entry(dictionary).State = EntityState.Modified; DictionariesRepository.Update(dictionary); } else { dictionary.Date = DateTime.Now; dictionary.ParentDictionaryId = null; DictionariesRepository.Insert(dictionary); } DictionariesRepository.Save(); dictionaryVo.TranslationList.ToList().ForEach(x => x.DictionaryId = dictionary.Id); var translations = dictionaryVo.TranslationList.Select(x => x.Id).ToList(); var currentTranslations = TranslationsRepository .GetAll() .Where(x => x.DictionaryId == dictionary.Id) .ToList(); var ids = currentTranslations.Select(x => x.Id).ToList(); var toDelete = currentTranslations.Where(x => !translations.Contains(x.Id)).ToList(); var toAdd = dictionaryVo.TranslationList?.Where(x => !ids.Contains(x.Id)).ToList() ?? new List <Translation>(); var toUpdate = dictionaryVo.TranslationList?.Where(x => ids.Contains(x.Id)).ToList() ?? new List <Translation>(); foreach (var trans in toDelete) { GameSessionTranslationsRepository.DeleteByTranslationId(trans.Id); TranslationsRepository.Delete(trans); } foreach (var trans in toUpdate) { TranslationsRepository.Update(trans); } foreach (var trans in toAdd) { TranslationsRepository.Insert(trans); } TranslationsRepository.Save(); transaction.Commit(); return(dictionary.Id); } catch (Exception) { transaction.Rollback(); return(-1); } } }