Esempio n. 1
0
        private void CreateDealer(ShowRoomDto apiDealer, int id = 0)
        {
            if (_cityRepository.GetQuery().Any(c => c.Id == apiDealer.CityId))
            {
                _dealerRepository.Add(new Dealer
                {
                    Id        = id == 0 ? apiDealer.Id : id,
                    Name      = apiDealer.Name,
                    CityId    = apiDealer.CityId,
                    Address   = apiDealer.Address,
                    CoFiCo    = apiDealer.Cofico,
                    Fax       = apiDealer.Fax,
                    Gssn      = apiDealer.Gssn,
                    Latitude  = apiDealer.Latitude,
                    Longitude = apiDealer.Longitude,
                    Phone     = apiDealer.Phone,
                    Url       = apiDealer.Site
                                //ToType = _dealerRepository.GetAll().Any(d => d.GSSN == apiDealer.Gssn) ? _dealerRepository.First(d => d.GSSN == apiDealer.Gssn).ToType : DealerToTypes.Other
                });

                //_connProjectsRepository.Add(new ConnProject {
                //     Id = apiDealer.Id
                //});
            }
            else
            {
                throw new Exception("CityId = " + apiDealer.CityId + " not exists");
            }

            _dealerRepository.SaveChanges();

            //_connProjectsRepository.SaveChanges();
        }
Esempio n. 2
0
        public void AddTest()
        {
            Mapper.Initialize(x => x.AddProfile <CustomizeProfile>());
            var mockSet     = new Mock <DbSet <ShowRoom> >();
            var mockContext = new Mock <LiveShowDBContext>();

            mockContext.Setup(x => x.ShowRoom).Returns(mockSet.Object);
            var mockSvc = new ShowRoomSvc(mockContext.Object);

            var dto = new ShowRoomDto()
            {
                Name = "Test", IsDeleted = false, Status = ShowRoomStatusEnum.Disable.GetHashCode(), CreateTime = DateTime.Now, LastActivateTime = DateTime.Now, Title = "TestTitle"
            };

            mockSvc.Add(dto);

            mockContext.Verify(x => x.Add(It.IsAny <ShowRoom>()), Times.Once);
            mockContext.Verify(x => x.SaveChanges(), Times.Once);
        }
Esempio n. 3
0
        public ResultDto Add(ShowRoomDto dto)
        {
            var result = new ResultDto();

            try
            {
                dto.SetDefaultValue();
                var data = Mapper.Map <ShowRoom>(dto);
                data.Disable();
                _liveShowDB.Add(data);
                var flag = _liveShowDB.SaveChanges();
                if (flag > 0)
                {
                    result.ActionResult = true;
                    result.Message      = "Success";
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            return(result);
        }
        public JsonResult Add(ShowRoomDto dto)
        {
            var result = _showRoomSvc.Add(dto);

            return(Json(result));
        }