public bool PersonExists(RegistrationData registrationData) { int roomTypeId, dormId; roomTypeId = RoomTypes.GetRoomTypeId(registrationData.RoomType); dormId = Dormitories.GetDormIdByName(registrationData.DormitoryName); int count = Persons.GetAll().Join( Agreements.GetAll(), p => p.id_person, a => a.person_id, (p, a) => new KeyValuePair <Person, Agreement>(p, a)).Where( x => (x.Key.surname == registrationData.Surname) && (x.Key.name == registrationData.Name) && (x.Key.is_living == true) && (x.Value.room_id == roomTypeId) && (x.Value.room_number == registrationData.RoomNumber) && (x.Value.dorm_id == dormId)).Select(res => res.Key.id_person).ToList().Count(); if (count == 1) { return(true); } else { return(false); } }
public string InsertNewPerson(NewPerson person, string admin_name, int dorm_id) { _context.InsertPerson( person.SurName, person.Name, person.LastName, person.Passport, person.IsMale, person.IsStudent, person.IsBudget, Countries.GetCountryId(person.Country), person.Contract, dorm_id, person.Floor, person.Room, RoomTypes.GetRoomTypeId(person.RoomTypeName), person.DateStart, person.DateFinish ); string description = "Добавление " + person.SurName + " " + person.Name + " " + person.Passport + " " + person.Country + ". Комната:" + " " + person.Room + " " + person.RoomTypeName; History.Add(new History { admin_name = admin_name, dorm_id = dorm_id, description = description, insertFlag = true }); return(description); }
public PersonData ConvertRegistrationDataToPersonData(RegistrationData registrationData) { int roomTypeId, dormId; roomTypeId = RoomTypes.GetRoomTypeId(registrationData.RoomType); dormId = Dormitories.GetDormIdByName(registrationData.DormitoryName); return(new PersonData { Name = registrationData.Name, SurName = registrationData.Surname, DormID = dormId, RoomType = roomTypeId, Room = registrationData.RoomNumber }); }
public IEnumerable <Population> GetPopulation(int dormId, int floor) { return(_context.GetPopulation(dormId, floor).Select( res => new Population { RoomType = res.roomName, Quantity = (int)res.Quantity, RoomNumber = res.roomNum, Gender = GetRoomGender( dormId, res.roomNum, RoomTypes.GetRoomTypeId(res.roomName) ) } ).ToList()); }
public string AddTariff(Tariff tariff, int dormId, string adminName) { try { bool is_active = ( ((tariff.DateFinish.HasValue == true) && (tariff.DateStart <= DateTime.Now.Date) && (tariff.DateFinish >= DateTime.Now.Date)) || ((tariff.DateFinish.HasValue == false) && (tariff.DateStart <= DateTime.Now.Date))) ? true : false; PriceList priceList = new PriceList { title = tariff.Title, price = tariff.Price, room_id = RoomTypes.GetRoomTypeId(tariff.RoomTypeName), is_student = tariff.IsStudent, on_budget = tariff.OnBudget, date_start = tariff.DateStart.Date, date_end = tariff.DateFinish.HasValue ? tariff.DateFinish.Value.Date : new DateTime?(), dorm_id = dormId, is_active = is_active }; if (Prices.isPriceListExisted(priceList) == false) { Prices.Add(priceList); History.Add(new History { admin_name = adminName, dorm_id = dormId, description = "Добавлен тариф, id которого " + Prices.GetAll().Select(x => x.id).Last(), addPriceFlag = true }); return(string.Empty); } else { return("Такой тариф уже есть в базе"); }; } catch (Exception ex) { return(ex.ToString()); } }
public IEnumerable <Population> GetPopulation(int dormId) { IEnumerable <int> _floors = Dormitories.GetLivingFloors(dormId); List <Population> _population = new List <Population>(); foreach (var floor in _floors) { _population.AddRange(_context.GetPopulation(dormId, floor).Select(res => new Population { RoomType = res.roomName, Quantity = (int)res.Quantity, RoomNumber = res.roomNum, Gender = GetRoomGender( dormId, res.roomNum, RoomTypes.GetRoomTypeId(res.roomName)) }).ToList()); } return(_population); }