public EquipmentBrandCreatedDomainEvent(
     EquipmentBrand equipmentBrand,
     string userId,
     bool active,
     DateTime createdAt
     )
 {
     EquipmentBrand = equipmentBrand;
     UserId         = userId;
     Active         = active;
     CreatedAt      = createdAt;
 }
Esempio n. 2
0
        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"
            });
        }
Esempio n. 3
0
 public void Update(EquipmentBrand equipmentBrand)
 {
     _context.Entry(equipmentBrand).State = EntityState.Modified;
 }
Esempio n. 4
0
 public EquipmentBrand Add(EquipmentBrand equipmentBrand)
 {
     return(_context.EquipmentBrand.Add(equipmentBrand).Entity);
 }