예제 #1
0
        public override Task <BusinessCreationResult> AddList(BusinessListCreationData list, ServerCallContext context)
        {
            var entities = new List <Database.Entities.Business>();

            foreach (var data in list.BusinessesCreationData)
            {
                var entity = new Database.Entities.Business()
                {
                    Id          = Guid.NewGuid().ToString(),
                    Name        = data.Name,
                    Tel         = data.Tel,
                    Address     = data.Address,
                    Email       = data.Email,
                    CreatedTime = DateTime.Now
                };
                entities.Add(entity);
            }
            _db.Businesses.AddRange(entities);
            var res = _db.SaveChanges() > 0;

            return(Task.FromResult(new BusinessCreationResult
            {
                Message = res ? "Success" : "Fail"
            }));
        }
예제 #2
0
        public IActionResult Add(BusinessDto dto)
        {
            var entity = new Database.Entities.Business()
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = dto.Name,
                Tel         = dto.Tel,
                Address     = dto.Address,
                Email       = dto.Email,
                CreatedTime = DateTime.Now
            };

            _db.Businesses.Add(entity);
            var res = _db.SaveChanges() == 1;

            return(Ok(res ? "Success" : "Fail"));
        }
예제 #3
0
        public override Task <BusinessCreationResult> Add(BusinessCreationData data, ServerCallContext context)
        {
            var entity = new Database.Entities.Business()
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = data.Name,
                Tel         = data.Tel,
                Address     = data.Address,
                Email       = data.Email,
                CreatedTime = DateTime.Now
            };

            _db.Businesses.Add(entity);
            var res = _db.SaveChanges() == 1;

            return(Task.FromResult(new BusinessCreationResult
            {
                Message = res ? "Success" : "Fail"
            }));
        }
예제 #4
0
        public IActionResult AddList(List <BusinessDto> dto)
        {
            var entities = new List <Database.Entities.Business>();

            foreach (var item in dto)
            {
                var entity = new Database.Entities.Business()
                {
                    Id          = Guid.NewGuid().ToString(),
                    Name        = item.Name,
                    Tel         = item.Tel,
                    Address     = item.Address,
                    Email       = item.Email,
                    CreatedTime = DateTime.Now
                };
                entities.Add(entity);
            }

            _db.Businesses.AddRange(entities);
            var res = _db.SaveChanges() > 0;

            return(Ok(res ? "Success" : "Fail"));
        }