public void CloseOrder(int orderId, int status) { var order = _context.Order.FirstOrDefault(x => x.Id == orderId); order.Status = status; try { _context.Entry(order).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); } catch (Exception e) { throw; } }
public void CreateNewNotification(int userId, int notifiedUserId, string template, string link) { var user = _context.User.FirstOrDefault(x => x.Id == userId); template = template.Replace("{Username}", user.Username); Notification notification = new Notification { UserId = notifiedUserId, CreatedDate = DateTime.Now, Link = link, Message = template }; try { _context.Notification.Add(notification); _context.SaveChanges(); } catch (Exception e) { throw; } }