/// <summary> /// Дабавить/редактировать /// </summary> /// <param name="name">Наимование</param> /// <param name="text">Тест статьи</param> /// <param name="author">Автор</param> /// <param name="headingID">Ссылка на рубрику</param> /// <param name="nameFile">Наимование файла</param> /// <param name="file">Файл</param> /// <param name="isDeleteFile">Удаление файла при редактирование</param> /// <param name="isNew">Новый</param> private void SetValue(string name, string text, string author, int headingID, string nameFile, byte[] file, bool isDeleteFile, bool isNew = true) { WorkForFiles workForFiles = WorkForFiles.New; if (isNew) { article = new Article(); article.DateCreate = DateTime.Now; workForFiles = WorkForFiles.New; } else { workForFiles = WorkForFiles.Edit; nameFile = "foto" + article.ID.ToString() + nameFile; } article.Name = name.Trim(); article.Text = text.Trim(); article.Author = author.Trim(); article.HeadingID = headingID; if (isNew) { dataContent.Articles.Add(article); } dataContent.SaveChanges(); if (workForFiles == WorkForFiles.New) { nameFile = "foto" + article.ID.ToString() + nameFile; if (file?.Length > 0) { article.FileName = nameFile; } else { article.FileName = string.Empty; } dataContent.SaveChanges(); if (file?.Length > 0) { WorkForFile(nameFile, string.Empty, file, isDeleteFile, WorkForFiles.New); } } else { WorkForFile(nameFile, article.FileName, file, isDeleteFile, WorkForFiles.Edit); if (file?.Length > 0 && (article.FileName == null || article.FileName == string.Empty)) { article.FileName = nameFile; dataContent.SaveChanges(); } else if (isDeleteFile) { article.FileName = string.Empty; dataContent.SaveChanges(); } } }
/// <summary> /// Дабавить/редактировать /// </summary> /// <param name="name">Наимование</param> /// <param name="linkPath">Путь в адресной строке</param> private void SetValue(string name, string linkPath, bool isNew = true) { if (isNew) { heading = new Heading(); } heading.Name = name.Trim(); heading.PathLink = linkPath; if (isNew) { dataContent.Headings.Add(heading); } dataContent.SaveChanges(); }
/// <summary> /// Дабавить/редактировать /// </summary> /// <param name="name">Наименование</param> /// <param name="isChangeRoom">Редактирование комнат</param> /// <param name="isEditUser">Добавление новых пользователей</param> /// <param name="isNew">Новый</param> private void SetValue(string name, bool isChangeRoom, bool isEditUser, bool isNew = true) { if (isNew) { role = new Role(); } role.Name = name.GetNotNull(); role.IsChangeRoom = isChangeRoom; role.IsEditUser = isEditUser; if (isNew) { dataContent.Roles.Add(role); } dataContent.SaveChanges(); }
/// <summary> /// Дабавить/редактировать /// </summary> /// <param name="name">Наименование</param> /// <param name="seatsCount">Количество кресел</param> /// <param name="isProjector">Наличие проектора</param> /// <param name="isMarkerBoard">Наличие маркерной доски</param> /// <param name="isBlock">Заблокировать комнату</param> /// <param name="isNew">Новый</param> private void SetValue(string name, int seatsCount, bool isProjector, bool isMarkerBoard, bool isBlock, bool isNew = true) { if (isNew) { room = new Room(); } room.Name = name.GetNotNull(); room.SeatsCount = seatsCount; room.IsProjector = isProjector; room.IsMarkerBoard = isMarkerBoard; room.IsBlock = isBlock; if (isNew) { dataContent.Rooms.Add(room); } dataContent.SaveChanges(); }
/// <summary> /// Дабавить/редактировать /// </summary> /// <param name="name">Наименование</param> /// <param name="seatsCount">Количество кресел</param> /// <param name="isProjector">Наличие проектора</param> /// <param name="isMarkerBoard">Наличие маркерной доски</param> /// <param name="isBlock">Заблокировать комнату</param> /// <param name="isNew">Новый</param> private void SetValue(DateTime mainDate, DateTime start, DateTime end, UserInfo user, RoomInfo room, OrderRoomStatus status, bool isNew = true) { if (isNew) { orderRoom = new OrderRoom(); orderRoom.UserID = user.ID; } orderRoom.Start = new DateTime(mainDate.Year, mainDate.Month, mainDate.Day, start.Hour, start.Minute, start.Second); orderRoom.End = new DateTime(mainDate.Year, mainDate.Month, mainDate.Day, end.Hour, end.Minute, end.Second); orderRoom.RoomID = room.ID; orderRoom.Status = (int)status; if (isNew) { dataContent.OrderRooms.Add(orderRoom); } dataContent.SaveChanges(); }
public IEnumerable <string> Get() { //return new string[] { "value1", "value2" }; for (int i = 0; i < 100; i++) { _content.Add(new User() { UserName = "******" + i }); } _content.SaveChanges(); return(new string[] { "ef to mysql demo" }); }
/// <summary> /// Дабавить/редактировать /// </summary> /// <param name="login">Логин</param> /// <param name="isPaswordChange">Изменить пароль</param> /// <param name="password">пароль</param> /// <param name="passwordReplay">Повторный пароль для проверки при изменение</param> /// <param name="oldPassword">Старый пароль при изменение</param> /// <param name="role">Роль</param> /// <param name="surName">Фамилия</param> /// <param name="middleName">Отчество</param> /// <param name="file">Файл</param> /// <param name="isDeleteFile">Удаление файла при редактирование</param> /// <param name="isNew">Новый</param> private void SetValue(string login, bool isPaswordChange, string password, string passwordReplay, string oldPassword, RoleInfo role, string surName, string name, string middleName, byte[] file, bool isDeleteFile, bool isNew = true) { WorkForFiles workForFiles = WorkForFiles.New; if (isNew) { user = new User(); workForFiles = WorkForFiles.New; } else { workForFiles = WorkForFiles.Edit; } user.Login = login.GetNotNull(); if (isPaswordChange) { user.Password = PasswordEncryption(password.GetNotNull()); } if (role != null) { user.RoleID = role.ID; } user.Name = name.GetNotNull(); user.SurName = surName.GetNotNull(); user.MiddleName = middleName.GetNotNull(); if (isNew) { dataContent.Users.Add(user); } dataContent.SaveChanges(); if (workForFiles == WorkForFiles.New) { user.IsPhoto = (file?.Length > 0); if (file?.Length > 0) { WorkForFile(login, file, isDeleteFile, WorkForFiles.New); } } else { if (file?.Length > 0) { user.IsPhoto = true; dataContent.SaveChanges(); } else if (isDeleteFile) { user.IsPhoto = false; dataContent.SaveChanges(); } WorkForFile(login, file, isDeleteFile, WorkForFiles.Edit); } }