public void Add(ScoreCard scoreCard) { foreach (var scorableCriterion in scoreCard.ScorableCriteria) { if (scorableCriterion != null) { ScorableCriterionRepo.Add(scorableCriterion); } } ScoreCardRepo.Add(scoreCard); }
public PrivateChat CreatePrivateChat(IUser self, IUser peer) { int id = _idProvider.NextId; PrivateChat chat = new PrivateChat( id, new SequentialIdentityProvider(), new FileRepo <IMessage>($".{id}.msg"), self, peer ); _chatRepo.Add(chat); return(chat); }
/// <summary> /// Start stracking the provded page by the provided tracker. /// </summary> public void StartTrackingPage(Page page, Tracker tracker) { TrackedPages.Add(new TrackedPage() { PageID = page.ID, TrackerID = tracker.ID }); }
public IActionResult CreateImg() { try { var file = HttpContext.Request.Form.Files.First(); if (file == null) { return(BadRequest()); } var userId = (HttpContext.Items["User"] as User).Id; var createImgMessageDto = new CreateImgMessageDto(file, userId); var model = _mapper.Map <ImageMessage>(createImgMessageDto); _repo.Add(model); var fileMessageReadDto = _mapper.Map <ReadImgMessageDto>(model); return(CreatedAtRoute(nameof(GetImgById), new { Id = fileMessageReadDto.Id }, fileMessageReadDto)); } catch (InvalidContentTypeException e) { return(BadRequest("Only images are allowed!")); } catch (Exception e) { return(StatusCode(500)); } }
public void AddEmployee() { Employee employee = new Employee(); employee.GetEmployeeDetails(); repo.Add(employee); }
public virtual int Create(T item) { var newItem = repo.Add(item); repo.Save(); return(newItem.Id); }
public IActionResult AddTextMessage(CreateUpdateClientMessageDto content) { if (content == null) { return(BadRequest("Value can't be null!")); } try { var userId = (HttpContext.Items["User"] as User).Id; var updateDeleteTextMessageDto = new CreateUpdateServerMessageDto() { Content = content.Content, UserId = userId }; var textMessage = _mapper.Map <TextMessage>(updateDeleteTextMessageDto); _repo.Add(textMessage); var readModel = _mapper.Map <ReadTextMessageDto>(textMessage); return(CreatedAtRoute(nameof(GetTextMessageById), new { Id = readModel.Id }, readModel)); } catch (Exception e) { return(StatusCode(500)); } }
public IActionResult Edit(EmployeeViewModel model) { _ = model ?? throw new ArgumentNullException(nameof(model)); if (!ModelState.IsValid) { return(View(model)); } var employee = mapper.Map <Employee>(model); if (model.Id == 0) { dataService.Add(employee); } else { dataService.Edit(employee); } try { dataService.SaveChanges(); } catch (Exception) { return(BadRequest()); } return(RedirectToAction("Index")); }
public void AddStock(IStock stock, int qty, decimal price) { _repo.Add(new StockPosition() { Stock = stock, Qty = qty, Price = price }); }
public async Task <Guid> Handle(CreateAddressRequest request, CancellationToken cancellationToken) { var entry = AddressBookEntry.Create(request.Line1, request.Line2, request.City, request.State, request.PostalCode); _repo.Add(entry); return(await Task.FromResult(entry.Id)); }
public void Get_Test() { var entity = Repo.Add(GenerateHelper.GenerateEntity <TEntity>()); var gotEntity = Repo.Get(x => x.Id == entity.Id); Assert.NotNull(gotEntity); foreach (var item in (typeof(TEntity)).GetProperties()) { if (item.PropertyType == typeof(DateTime)) { continue; } Assert.Equal(item.GetValue(entity), item.GetValue(gotEntity)); } }
public int Add([FromBody] Employee entity) { logger.LogInformation("Adding a new employee: [{0}]{1} {2} {3}", entity.Id, entity.Surname, entity.Firstname); var id = employeesRepo.Add(entity); SaveChanges(); return(id); }
public void InsertLog(Exception ex, LogLevel logLevel) { _repo.Add(new NotifierLog { LogLevel = (short)logLevel, Message = ex.Message, StackTrace = ex.ToString(), }); }
public virtual async Task <Result> Add(T entity) { bool isAdded = await _repository.Add(entity); if (isAdded) { return(Result.Success()); } return(Result.Failure(new[] { "Unable to save data!" })); }
private void AddOrUpdatePerformance(Performance performance) { if (!PerformanceRepo.Exists(performance.Id)) { PerformanceRepo.Add(performance); } else { PerformanceRepo.Update(performance); } }
public ActionResult Create([Bind(Include = "PublisherId,PublisherName,Address")] Publisher publisher) { if (ModelState.IsValid) { db.Add(publisher); db.Commit(); return(RedirectToAction("Index")); } return(View(publisher)); }
/// <summary> /// Add or Update record depends on its Id. /// If id is null then record will be saved. /// If Id is not null then record will be updated. /// </summary> /// <param name="entity">the entity of save or update action</param> /// <returns>itself after action perform</returns> public virtual T Save(T entity) { if (entity.Id == null) { return(_repo.Add(entity)); } else { return(_repo.Update(entity)); } }
public ActionResult<T> AddOne(T entity) { try { MainRepo.Add(entity); } catch (Exception ex) { return BadRequest(ex); } return CreatedAtAction(nameof(GetOne), new { id = entity.Id }, entity); }
public ActionResult Create(Profile p) { try { _Repo.Add(p); } catch (Exception e) { _Logger.LogDebug(e.Message); } return(RedirectToAction(nameof(Index))); }
public IUser CreateUser(string name, string password) { int id = _idProvider.NextId; User user = new User( id, name, new SHA256PasswordHandler(password) ); _userRepo.Add(user); return(user); }
public IActionResult Create(Profile profile) { try { _repo.Add(profile); return(RedirectToAction("Index")); } catch { return(RedirectToAction("Error")); } }
private void AddTableData() { bool mandatoryField = false; while (mandatoryField == false) { Console.Write("Insert Title: *"); string title = Console.ReadLine(); if (string.IsNullOrEmpty(title)) { Console.WriteLine("Title can't be empty! Input title once again."); } else { mandatoryField = true; Console.Write("Insert ReleaseDate: "); int releaseDate; while (!int.TryParse(Console.ReadLine(), out releaseDate)) { Console.Write("Please enter number. Release date:"); } Console.Write("Insert Rating: "); double rating; while (!double.TryParse(Console.ReadLine(), out rating)) { Console.Write("Please enter double. Rating:"); } Console.Write("Insert Genre: "); string genre = Console.ReadLine(); Console.Write("Insert Director: "); string director = Console.ReadLine(); Console.Write("Insert Starts: "); string star = Console.ReadLine(); moviesRepo.Add(new Movie() { Title = title, ReleaseDate = releaseDate, Rating = rating, Genre = genre, Director = director, Stars = star }); } } }
public bool TrySendMessage(IUser user, string body) { IMember member = Members.SingleOrDefault(m => m.User == user); if (body != null && member != null && member.Role.Permissions.Contains(Permission.Send)) { _messageRepo.Add(new Message(_idProvider.NextId, DateTime.Now, user, this, body)); return(true); } return(false); }
public TelegramGroup AddGroupIfNotExist(TelegramGroup input) { var chat = _repo.Get(x => x.ChatId == input.ChatId); if (chat == null) { return(_repo.Add(input)); } else { return(_repo.Update(chat)); } }
public IActionResult Post([FromBody] Branch branch) { if (branch == null) { return(BadRequest("employee is null")); } else { _repo.Add(branch); var model = _mapper.Map <BranchVM>(branch); return(Ok(model)); } }
public User AddUserIfNotExist(User input) { var user = _repo.Get(x => x.TelegramId == input.TelegramId); if (user == null) { return(_repo.Add(input)); } else { return(_repo.Update(user)); } }
public IActionResult Post([FromBody] Customer customers) { if (customers == null) { return(BadRequest("employee is null")); } else { _repo.Add(customers); var model = _mapper.Map <CustomerVM>(customers); return(Ok(model)); } }
public IActionResult Put(int id, Todos item) { try { item.ID = id; _context.Add(item); return(Ok()); } catch (Exception) { return(NotFound()); } }
public ActionResult AddTask(TaskModel model) { _tasksRepo.Add(new Task { Name = model.Name, Description = model.Description, StartDate = model.StartDate, Duration = model.Duration, Status = model.Status }); return(RedirectToAction("ShowTable")); }
public UserRss AddRssIfNotExist(UserRss input) { var rss = _repo.Get(x => x.UserId == input.UserId && x.Url == input.Url.Trim()); if (rss == null) { return(_repo.Add(input)); } else { return(_repo.Update(rss)); } }