public EquipmentBrandCreatedDomainEvent( EquipmentBrand equipmentBrand, string userId, bool active, DateTime createdAt ) { EquipmentBrand = equipmentBrand; UserId = userId; Active = active; CreatedAt = createdAt; }
public async Task <Response> UpsertEquipmentBrand(UpsertEquipmentBrandCmd request) { ///// var existItem = await _context.EquipmentBrands.AnyAsync(x => x.Name == request.Name); if (existItem) { throw new BusinessLogicException(".این رکورد از قبل موجود می باشد"); } ///// if (!string.IsNullOrEmpty(request.Id)) { var item = await _context.EquipmentBrands.SingleOrDefaultAsync(x => x.Id == request.Id); if (item == null) { throw new BusinessLogicException("رکوردی یافت نشد"); } item.Name = request.Name; _context.EquipmentBrands.Update(item); } else { var item = new EquipmentBrand { Id = Guid.NewGuid().ToString(), Name = request.Name, CreatedAt = DateTime.Now }; await _context.EquipmentBrands.AddAsync(item); } await _context.SaveChangesAsync(); return(new Response { Status = true, Message = "success" }); }
public void Update(EquipmentBrand equipmentBrand) { _context.Entry(equipmentBrand).State = EntityState.Modified; }
public EquipmentBrand Add(EquipmentBrand equipmentBrand) { return(_context.EquipmentBrand.Add(equipmentBrand).Entity); }