コード例 #1
0
        public void Create(BookLoan bookloan)
        {
            BookLoan.Add(bookloan);
            var book = GetBookById(bookloan.BookId);

            book.BookAmount = book.BookAmount - 1;
            Book.Update(book);
        }
コード例 #2
0
        public IActionResult CreatePerson([FromBody] PersonCreateRequest personCreateRequest)
        {
            Person person = _mapper.Map <Person>(personCreateRequest);

            _entityRepository.Add(person);
            _unitOfWork.Commit();
            return(Ok());
        }
 public static void AddRange <TEntity>(this IGenericRepository @this, IEnumerable <TEntity> entities)
     where TEntity : class
 {
     foreach (var entity in entities)
     {
         @this.Add(entity);
     }
 }
コード例 #4
0
        public async Task <WebsiteTextDto> AddText(AddWebsiteTextDto textDto)
        {
            var text = _mapper.Map <WebsiteText>(textDto);

            text = await _repo.Add(text);

            return(_mapper.Map <WebsiteTextDto>(text));
        }
コード例 #5
0
ファイル: MessageService.cs プロジェクト: bagasssss/trip
        public async Task <Message> Send(Message message)
        {
            message.SentDt = DateTime.UtcNow;
            _repository.Add(message);
            await _repository.SaveChanges();

            return(message);
        }
コード例 #6
0
        public void AddRating(Rating rating)
        {
            var user = _repo.Query <ApplicationUser>().Where(u => u.Id == rating.UserBeingRated).FirstOrDefault();

            rating.TimeStamp = DateTime.Now;
            rating.User      = user;
            _repo.Add(rating);
        }
コード例 #7
0
 public void SaveCalendarEvent(CalendarEvent calendarEventToSave, string uid)
 {
     calendarEventToSave.isActive = true;
     if (calendarEventToSave.Id == 0)
     {
         // get currently logged in user by uid to assign as eventOwner
         ApplicationUser currUser = _repo.Query <ApplicationUser>().Where(u => u.Id == uid).FirstOrDefault();
         calendarEventToSave.EventOwner  = currUser;
         calendarEventToSave.CreatedDate = DateTime.Now;
         calendarEventToSave.EventType   = "playdate";
         _repo.Add(calendarEventToSave); // saves the new entry to the database
     }
     else
     {
         _repo.Update(calendarEventToSave);
     }
 }
コード例 #8
0
        /// <summary>
        /// Adds to do list.
        /// </summary>
        /// <param name="todolist">The todolist.</param>
        /// <returns></returns>
        public ToDoListDTO AddToDoList(ToDoListDTO todolist)
        {
            ToDoListEntity entity = _mapper.Map <ToDoListDTO, ToDoListEntity>(todolist);

            entity.CreatedDate = DateTime.Now;
            _repo.Add(entity);
            return(todolist);
        }
コード例 #9
0
        public void AddCustomer(CustomerDTO item)
        {
            var entity = Mapper.Map <Customer>(item);

            _customers.Add(entity);

            Save();
        }
コード例 #10
0
ファイル: TeamService.cs プロジェクト: kpinniss/GameSquad
        public int SaveTeam(Team team)
        {
            if (team.Id == 0)
            {
                _repo.Add(team);
                return(team.Id);
            }

            else
            {
                var ttu = _repo.Query <Team>().Where(t => t.Id == team.Id).FirstOrDefault();
                ttu.PlayStyle = team.PlayStyle;
                ttu.TeamName  = team.TeamName;
                _repo.SaveChanges();
                return(0);
            }
        }
コード例 #11
0
        public virtual TEntityDTo Add(TEntityDTo entityDTo)
        {
            var entity = AutoMapperHelper.Map <TEntityDTo, TEntity>(entityDTo);
            var result = _repo.Add(entity);

            _unitOfWork.SaveChanges();
            return(AutoMapperHelper.Map <TEntity, TEntityDTo>(result));
        }
コード例 #12
0
 public void Add(ManufacturerDTO item)
 {
     repository.Add(new Manufacturer
     {
         ManufacturerId   = item.ManufacturerId,
         ManufacturerName = item.ManufacturerName
     });
 }
コード例 #13
0
        public void AddTaskList(string ListName)
        {
            TaskList newTaskList = new TaskList();

            newTaskList.Name = ListName;
            _repo.Add(newTaskList);
            _repo.SaveChanges();
        }
コード例 #14
0
        public ContactResponseContract Add(ContactRequestContract requestContract)
        {
            var requestContact = Mapper.Map <Contact>(requestContract);

            var contact = _contactRepository.Add(requestContact);

            return(Mapper.Map <ContactResponseContract>(contact));
        }
コード例 #15
0
        public TBEntity Add(TBEntity obj)
        {
            var dbEntity = _mapper.Map <TEnity>(obj);

            _repository.Add(dbEntity);
            _repository.Save();
            return(_mapper.Map <TBEntity>(dbEntity));
        }
コード例 #16
0
 public IActionResult AddDirector(Director director)
 {
     if (ModelState.IsValid)
     {
         _directorRepository.Add(director);
     }
     return(RedirectToAction("Create", "Movie"));
 }
コード例 #17
0
        // adds a movie
        public void AddMovie(Movie movie)
        {
            Category cat = _cService.GetCategoryNoMovies(movie.Category.Id);

            movie.Category = cat;

            _repo.Add(movie);
        }
コード例 #18
0
        public bool Insert(BILL_EFFECTSVM entity)
        {
            BILL_EFFECTS be = new BILL_EFFECTS
            {
                AddedBy          = entity.AddedBy,
                AddedOn          = entity.AddedOn,
                BILL_EFF_AR_NAME = entity.BILL_EFF_AR_NAME,
                BILL_EFF_EN_NAME = entity.BILL_EFF_EN_NAME,
                BILL_EFF_ID      = entity.BILL_EFF_ID,
                Disable          = entity.Disable,
                UpdatedBy        = entity.UpdatedBy,
                updatedOn        = entity.updatedOn
            };

            billEffectsRepo.Add(be);
            return(true);
        }
コード例 #19
0
        public void AddManager(ManagerDTO item)
        {
            var entity = Mapper.Map <Manager>(item);

            _managers.Add(entity);

            Save();
        }
コード例 #20
0
        public void AddSubCategory(SubCategory subCategory)
        {
            Category category = _catService.GetCategory(subCategory.Category.Id);

            subCategory.Category = category;

            _repo.Add(subCategory);
        }
コード例 #21
0
        public bool Insert(TelephoneVM entity)
        {
            Telephones tel = new Telephones()
            {
                TELE_ID      = entity.TELE_ID,
                TELE_CAT_ID  = entity.TELE_CAT_ID,
                TELE_NUMBER  = entity.TELE_NUMBER,
                TELE_TYPE_ID = entity.TELE_TYPE_ID,
                AddedBy      = entity.AddedBy,
                AddedOn      = entity.AddedOn,
                UpdatedBy    = entity.UpdatedBy,
                updatedOn    = entity.updatedOn
            };

            telephoneRepo.Add(tel);
            return(true);
        }
コード例 #22
0
 public IActionResult AddGenre(Genre genre)
 {
     if (ModelState.IsValid)
     {
         _genreRepository.Add(genre);
     }
     return(RedirectToAction("Create", "Movie"));
 }
コード例 #23
0
 public void Create(T entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException(nameof(entity));
     }
     _repository.Add(entity);
 }
コード例 #24
0
        public bool Insert(Income_Account_TypesVM entity)
        {
            Income_Account_Types accType = new Income_Account_Types
            {
                ID        = entity.ID,
                NameAr    = entity.NameAr,
                NameEn    = entity.NameEn,
                AddedBy   = entity.AddedBy,
                AddedOn   = entity.AddedOn,
                disable   = entity.disable,
                UpdatedOn = entity.UpdatedOn,
                UpdatedBy = entity.UpdatedBy
            };

            incomeAccTypRepo.Add(accType);
            return(true);
        }
コード例 #25
0
        public void AddItem(ItemDTO item)
        {
            var entity = Mapper.Map <Item>(item);

            _items.Add(entity);

            Save();
        }
コード例 #26
0
        public void AddOrder(OrderDTO item)
        {
            var entity = Mapper.Map <Order>(item);

            _orders.Add(entity);

            Save();
        }
コード例 #27
0
        public async Task <TNewEntity> Create <TNewEntity>(TNewEntity newEntity)
            where TNewEntity : class, ISimpleEntity
        {
            _repository.Add(newEntity);
            await _repository.SaveChanges();

            return(newEntity);
        }
コード例 #28
0
        public bool Insert(AccountDetailVM entity)
        {
            ACCOUNT_DETAILS emp = new ACCOUNT_DETAILS
            {
                AddedBy             = entity.AddedBy,
                AddedOn             = entity.AddedOn,
                CHILD_ACC_ID        = entity.CHILD_ACC_ID,
                Disable             = entity.Disable,
                PARENT_ACC_ID       = entity.PARENT_ACC_ID,
                PARTITIONING_FACTOR = entity.PARTITIONING_FACTOR,
                UpdatedBy           = entity.UpdatedBy,
                UpdatedOn           = entity.UpdatedOn
            };

            _ACCOUNT_DETAILSRepo.Add(emp);
            return(true);
        }
コード例 #29
0
        public async Task <Subject> Add(Subject subject)
        {
            await _genericRepository.Add(subject);

            await _genericRepository.SaveAsync();

            return(subject);
        }
コード例 #30
0
        public View_EVoucherUserDTO Add(View_EVoucherUserDTO entityDTo)
        {
            var entity = AutoMapperHelper.Map <View_EVoucherUserDTO, View_EVoucherUser>(entityDTo);
            var result = _vRepo.Add(entity);

            _unitOfWork.SaveChanges();
            return(AutoMapperHelper.Map <View_EVoucherUser, View_EVoucherUserDTO>(result));
        }
コード例 #31
0
        public void Initialize()
        {
            users = new GenericRepository<User>(new FakeStorageContext<User>());

            roles = new FakeRoles();
            webSecurity = new FakeWebSecurity(roles, users);

            controller = new UsersController(users, roles, webSecurity);

            users.Add(new User()
            {
                ID = 1,
                username = "******",
                realName = "Administrator"
            });

            users.Add(new User()
            {
                ID = 2,
                username = "******",
                realName = "Advisor"
            });
        }
コード例 #32
0
        public void Initialize()
        {
            plans = new GenericRepository<Plan>(new FakeStorageContext<Plan>());
            planCourses = new GenericRepository<PlanCourse>(new FakeStorageContext<PlanCourse>());
            semesters = new GenericRepository<Semester>(new FakeStorageContext<Semester>());
            users = new GenericRepository<User>(new FakeStorageContext<User>());
            degreePrograms = new GenericRepository<DegreeProgram>(new FakeStorageContext<DegreeProgram>());

            roles = new FakeRoles();
            webSecurity = new FakeWebSecurity(roles, users);

            controller = new PlansController(plans, planCourses, semesters, users, degreePrograms, roles, webSecurity);

            degreePrograms.Add(new DegreeProgram()
            {
                ID = 1,
                degreeProgramName = "Degree Program 1"
            });

            degreePrograms.Add(new DegreeProgram()
            {
                ID = 2,
                degreeProgramName = "Degree Program 2"
            });

            users.Add(new User()
            {
                ID = 1,
                username = "******",
                realName = "Test User 1"
            });

            users.Add(new User()
            {
                ID = 2,
                username = "******",
                realName = "Test User 2"
            });

            users.Add(new User()
            {
                ID = 3,
                username = "******",
                realName = "Administrator"
            });

            users.Add(new User()
            {
                ID = 4,
                username = "******",
                realName = "Advisor"
            });

            semesters.Add(new Semester()
            {
                ID = 1,
                semesterTitle = "Fall",
                semesterYear = 2013,
                standard = true
            });

            semesters.Add(new Semester()
            {
                ID = 2,
                semesterTitle = "Spring",
                semesterYear = 2014,
                standard = true
            });

            plans.Add(new Plan()
            {
                ID = 1,
                planName = "Plan 1",
                degreeProgramID = 1,
                degreeProgram = degreePrograms.Find(1),
                userID = 1,
                //user = users.Find(1),
                semesterID = 1,
                semester = semesters.Find(1),
                planCourses = new Collection<PlanCourse>()
            });

            plans.Add(new Plan()
            {
                ID = 2,
                planName = "Plan 2",
                degreeProgramID = 2,
                degreeProgram = degreePrograms.Find(2),
                userID = 2,
                //user = users.Find(2),
                semesterID = 2,
                semester = semesters.Find(2),
                planCourses = new Collection<PlanCourse>()
            });
        }
コード例 #33
0
        public void Initialize()
        {
            degreePrograms = new GenericRepository<DegreeProgram>(new FakeStorageContext<DegreeProgram>());
            requiredCourses = new GenericRepository<RequiredCourse>(new FakeStorageContext<RequiredCourse>());
            electiveCourses = new GenericRepository<ElectiveCourse>(new FakeStorageContext<ElectiveCourse>());
            electiveLists = new GenericRepository<ElectiveList>(new FakeStorageContext<ElectiveList>());
            courses = new GenericRepository<Course>(new FakeStorageContext<Course>());

            controller = new DegreeProgramsController(degreePrograms, requiredCourses, electiveCourses, electiveLists, courses);

            courses.Add(new Course()
            {
                ID = 1,
                coursePrefix = "AAA",
                courseNumber = 123,
                courseTitle = "Test Course 1",
                courseDescription = "This is a test course for the testing framework.",
                minHours = 3,
                maxHours = 4,
                undergrad = true,
                variable = false,
            });
            courses.Add(new Course()
            {
                ID = 2,
                coursePrefix = "BBB",
                courseNumber = 456,
                courseTitle = "Test Course 2",
                courseDescription = "This is a test course for the testing framework.",
                minHours = 5,
                maxHours = 6,
                graduate = true,
                variable = false,
            });
            courses.Add(new Course()
            {
                ID = 3,
                coursePrefix = "AAA",
                courseNumber = 122,
                courseTitle = "Test Course 3",
                courseDescription = "This is a test course for the testing framework.",
                minHours = 7,
                maxHours = 8,
                undergrad = true,
                variable = true,
            });

            electiveLists.Add(new ElectiveList()
            {
                ID = 1,
                electiveListName = "Elective List 1",
            });
            electiveLists.Add(new ElectiveList()
            {
                ID = 2,
                electiveListName = "Elective List 2",
            });

            degreePrograms.Add(new DegreeProgram()
            {
                ID = 1,
                degreeProgramName = "Degree Program 1",
                requiredCourses = new Collection<RequiredCourse>(),
                electiveCourses = new Collection<ElectiveCourse>(),
            });
            degreePrograms.Add(new DegreeProgram()
            {
                ID = 2,
                degreeProgramName = "Degree Program 2",
                requiredCourses = new Collection<RequiredCourse>(),
                electiveCourses = new Collection<ElectiveCourse>(),
            });

            requiredCourses.Add(new RequiredCourse()
            {
                ID = 1,
                courseID = 1,
                course = courses.Find(1),
                degreeProgramID = 1,
                semester = 3,
            });
            requiredCourses.Add(new RequiredCourse()
            {
                ID = 2,
                courseID = 2,
                course = courses.Find(2),
                degreeProgramID = 1,
                semester = 2,
            });
            requiredCourses.Add(new RequiredCourse()
            {
                ID = 3,
                courseID = 3,
                course = courses.Find(3),
                degreeProgramID = 1,
                semester = 1,
            });

            degreePrograms.Find(1).requiredCourses.Add(requiredCourses.Find(1));
            degreePrograms.Find(1).requiredCourses.Add(requiredCourses.Find(2));
            degreePrograms.Find(1).requiredCourses.Add(requiredCourses.Find(3));

            electiveCourses.Add(new ElectiveCourse()
            {
                ID = 1,
                electiveListID = 1,
                electiveList = electiveLists.Find(1),
                degreeProgramID = 1
            });
            electiveCourses.Add(new ElectiveCourse()
            {
                ID = 2,
                electiveListID = 2,
                electiveList = electiveLists.Find(2),
                degreeProgramID = 1
            });

            degreePrograms.Find(1).electiveCourses.Add(electiveCourses.Find(1));
            degreePrograms.Find(1).electiveCourses.Add(electiveCourses.Find(2));
        }
コード例 #34
0
ファイル: Excel.cs プロジェクト: TeamCurrant/GirlsAgency
        private static void ImportGirlsToDatabase(IEnumerable<Girl> list, IGenericRepository<Girl> sqlRepo)
        {
            foreach (var girl in list)
            {
                sqlRepo.Add(girl);
            }

            sqlRepo.SaveChanges();
        }
コード例 #35
0
        public void Initialize()
        {
            electiveLists = new GenericRepository<ElectiveList>(new FakeStorageContext<ElectiveList>());
            courses = new GenericRepository<Course>(new FakeStorageContext<Course>());
            electiveListCourses = new GenericRepository<ElectiveListCourse>(new FakeStorageContext<ElectiveListCourse>());

            controller = new ElectiveListsController(electiveLists, courses, electiveListCourses);

            courses.Add(new Course(){
                ID = 1,
                coursePrefix = "AAA",
                courseNumber = 123,
                courseTitle = "Test Course 1",
                courseDescription = "This is a test course for the testing framework.",
                minHours = 3,
                maxHours = 4,
                undergrad = true,
                variable = false,
                electiveLists = new List<ElectiveListCourse>(),
            });
            courses.Add(new Course()
            {
                ID = 2,
                coursePrefix = "BBB",
                courseNumber = 456,
                courseTitle = "Test Course 2",
                courseDescription = "This is a test course for the testing framework.",
                minHours = 5,
                maxHours = 6,
                graduate = true,
                variable = false,
                electiveLists = new List<ElectiveListCourse>()
            });
            courses.Add(new Course(){
                ID = 3,
                coursePrefix = "AAA",
                courseNumber = 122,
                courseTitle = "Test Course 3",
                courseDescription = "This is a test course for the testing framework.",
                minHours = 7,
                maxHours = 8,
                undergrad = true,
                variable = true,
                electiveLists = new List<ElectiveListCourse>()
            });

            electiveLists.Add(new ElectiveList()
            {
                ID = 1,
                electiveListName = "Elective List 1",
                courses = new List<ElectiveListCourse>(),
            });
            electiveLists.Add(new ElectiveList()
            {
                ID = 2,
                electiveListName = "Elective List 2",
                courses = new List<ElectiveListCourse>(),
            });

            electiveListCourses.Add(new ElectiveListCourse()
            {
                ID = 1,
                electiveListID = 1,
                courseID = 1,
                course = courses.Find(1),
            });
            electiveListCourses.Add(new ElectiveListCourse()
            {
                ID = 2,
                electiveListID = 1,
                courseID = 2,
                course = courses.Find(2),
            });
            electiveListCourses.Add(new ElectiveListCourse()
            {
                ID = 3,
                electiveListID = 3,
                courseID = 3,
                course = courses.Find(3),
            });

            electiveLists.Find(1).courses.Add(electiveListCourses.Find(1));
            electiveLists.Find(1).courses.Add(electiveListCourses.Find(2));
            electiveLists.Find(2).courses.Add(electiveListCourses.Find(3));

            courses.Find(1).electiveLists.Add(electiveListCourses.Find(1));
            courses.Find(2).electiveLists.Add(electiveListCourses.Find(2));
            courses.Find(3).electiveLists.Add(electiveListCourses.Find(3));
        }
コード例 #36
0
ファイル: Excel.cs プロジェクト: TeamCurrant/GirlsAgency
        private static void ImportCustomersToDatabase(IEnumerable<Customer> list, IGenericRepository<Customer> repo)
        {
            foreach (var customer in list)
            {
                repo.Add(customer);
               // mySqlRepo.Add(customer);
            }

            repo.SaveChanges();
               // mySqlRepo.SaveChanges();
        }