public bool UpdateFile(FilesApiModel _FilesApiModel) { try { File _File = new File(); using (var Entity = new WebMailEntities()) { int _id = _FilesApiModel.Id; _File = Entity.Files.Where(z => z.Id == _id).FirstOrDefault(); if (_File != null) { _File.IsValid = _FilesApiModel.IsValid; _File.Name = _FilesApiModel.Name; _File.Path = _FilesApiModel.Path; _File.TypeId = _FilesApiModel.TypeId; Entity.SaveChanges(); } } return(true); } catch (Exception ex) { return(false); } }
public bool SaveNewFile(FilesApiModel _FilesApiModel) { try { if (ModelState.IsValid) { File _File = new File(); _File.FolderId = Convert.ToInt32(_FilesApiModel.FolderId); _File.IsValid = _FilesApiModel.IsValid; _File.Name = _FilesApiModel.Name; _File.Path = _FilesApiModel.Path; _File.StatusId = 1; using (var Entity = new WebMailEntities()) { Entity.Files.Add(_File); Entity.SaveChanges(); } return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public bool AddEditFolder(MailBoxFolderModel Model) { try { MailBoxFolder _MailBoxFolders = new MailBoxFolder(); //For Add if (string.IsNullOrEmpty(Model.MailBoxFolderId.ToString()) || Model.MailBoxFolderId == 0) { using (var Entity = new WebMailEntities()) { _MailBoxFolders.MailBoxFolderName = Model.MailBoxFolderName; _MailBoxFolders.MailBoxId = Model.MailBoxId; _MailBoxFolders.Sequence = 0; _MailBoxFolders.IsActive = true; Entity.MailBoxFolders.Add(_MailBoxFolders); Entity.SaveChanges(); } } else { using (var Entity = new WebMailEntities()) { MailBoxFolder _MailBoxUpdate = Entity.MailBoxFolders.Where(s => s.MailBoxFolderId == Model.MailBoxFolderId).FirstOrDefault(); if (_MailBoxUpdate != null) { _MailBoxUpdate.MailBoxFolderName = Model.MailBoxFolderName; _MailBoxUpdate.MailBoxId = Model.MailBoxId; Entity.SaveChanges(); } } } using (var entity = new WebMailEntities()) { var SequenceArry = Model.Sequenseids.Split(','); for (int i = 0; i < SequenceArry.Count(); i++) { MailBoxFolder _UpdateSequence = new MailBoxFolder(); if (SequenceArry[i].ToString() == "NEWREC") { _UpdateSequence = entity.MailBoxFolders.SingleOrDefault(b => b.MailBoxFolderId == _MailBoxFolders.MailBoxFolderId); } else { Int32 id = Convert.ToInt32(SequenceArry[i].ToString()); _UpdateSequence = entity.MailBoxFolders.SingleOrDefault(b => b.MailBoxFolderId == id); } _UpdateSequence.Sequence = i + 1; entity.SaveChanges(); } } return(true); } catch (Exception ex) { return(false); } }
public bool AddEditFolder(FolderApiModel Model) { try { if (Model.TypeId == "0") { using (var Entity = new WebMailEntities()) { int _MailBoxid = Convert.ToInt32(Model.MailBoxId); List <Folder> _FolderList = Entity.Folders.Where(s => s.MailBoxId == _MailBoxid).ToList(); _FolderList.ForEach(s => s.TypeId = 1); Entity.SaveChanges(); } } Folder _Folders = new Folder(); //For Add if (string.IsNullOrEmpty(Model.Id.ToString()) || Model.Id == 0) { using (var Entity = new WebMailEntities()) { _Folders.MailBoxId = Convert.ToInt32(Model.MailBoxId); _Folders.Name = Model.Name; _Folders.StatusId = Convert.ToByte(Model.StatusId); _Folders.TypeId = Convert.ToByte(Model.TypeId); _Folders.StatusId = 1; Entity.Folders.Add(_Folders); Entity.SaveChanges(); } } else { using (var Entity = new WebMailEntities()) { Folder _FoldersUpdate = Entity.Folders.Where(s => s.Id == Model.Id).FirstOrDefault(); if (_FoldersUpdate != null) { _FoldersUpdate.MailBoxId = Convert.ToInt32(Model.MailBoxId); _FoldersUpdate.Name = Model.Name; _FoldersUpdate.StatusId = 1; _FoldersUpdate.TypeId = Convert.ToByte(Model.TypeId); Entity.SaveChanges(); } } } return(true); } catch (Exception ex) { return(false); } }
public IHttpActionResult UpdateEmailDetailes([ModelBinder(typeof(WebApiDataSourceRequestModelBinder))] DataSourceRequest request, FilesApiModel _FilesApiModel) { if (_FilesApiModel.FolderId == "Disable") { using (var Entity = new WebMailEntities()) { File Files = Entity.Files.Where(s => s.Id == _FilesApiModel.Id).FirstOrDefault(); if (Files != null) { Files.StatusId = 0; Entity.SaveChanges(); } } } else if (_FilesApiModel.FolderId == "Deleted") { using (var Entity = new WebMailEntities()) { File Mail = Entity.Files.Where(s => s.Id == _FilesApiModel.Id).FirstOrDefault(); if (Mail != null) { Entity.Files.Remove(Mail); Entity.SaveChanges(); } } } else { using (var Entity = new WebMailEntities()) { File target = Entity.Files.Where(x => x.Id == _FilesApiModel.Id).FirstOrDefault(); if (target != null) { int _FolderId = Convert.ToInt32(_FilesApiModel.FolderId); target.FolderId = _FolderId; target.IsValid = _FilesApiModel.IsValid; target.Name = _FilesApiModel.Name; target.Path = _FilesApiModel.Path; // target.StatusId = _FilesApiModel.StatusId; target.TypeId = _FilesApiModel.TypeId; Entity.SaveChanges(); } } } return(Json(new[] { _FilesApiModel }.ToDataSourceResult(request))); }
public bool UpdateMailStatus(string Id, string flag) { try { int _Id = Convert.ToInt32(Id); using (var Entity = new WebMailEntities()) { Mail _Mail = Entity.Mails.Where(x => x.MessageID == _Id).FirstOrDefault(); if (_Mail != null) { _Mail.Status = flag; Entity.SaveChanges(); } } return(true); } catch (Exception ex) { return(false); } }
public bool SaveNewEmail(MailViewModel _MailViewModel) { try { Mail _Mail = new Mail(); _Mail.Category = Convert.ToInt32(_MailViewModel.Category); _Mail.IsValid = _MailViewModel.IsValid; _Mail.Name = _MailViewModel.Name; _Mail.Url = _MailViewModel.Url; using (var Entity = new WebMailEntities()) { Entity.Mails.Add(_Mail); Entity.SaveChanges(); } return(true); } catch (Exception ex) { return(false); } }
public bool UpdateFileStatus(string Id, string StatusId) { try { int _Id = Convert.ToInt32(Id); byte _StatusId = Convert.ToByte(StatusId); using (var Entity = new WebMailEntities()) { File _File = Entity.Files.Where(x => x.Id == _Id).FirstOrDefault(); if (_File != null) { _File.StatusId = _StatusId; Entity.SaveChanges(); } } return(true); } catch (Exception ex) { return(false); } }
public bool FunctionDeleteFolder(string Id) { try { long _Id = Convert.ToInt32(Id); MailBoxFolder _MailBoxFolders = new MailBoxFolder(); using (var Entity = new WebMailEntities()) { MailBoxFolder _MailBoxUpdate = Entity.MailBoxFolders.Where(s => s.MailBoxFolderId == _Id).FirstOrDefault(); if (_MailBoxUpdate != null) { _MailBoxUpdate.IsActive = false; Entity.SaveChanges(); } } return(true); } catch (Exception ex) { return(false); } }
public bool DeleteFolder(string Id) { try { long _Id = Convert.ToInt32(Id); Folder _Folder = new Folder(); using (var Entity = new WebMailEntities()) { _Folder = Entity.Folders.Where(s => s.Id == _Id).FirstOrDefault(); if (_Folder != null) { _Folder.StatusId = 0; Entity.SaveChanges(); } } return(true); } catch (Exception ex) { return(false); } }