Exemplo n.º 1
0
        public static string Update(string temp)
        {
            JObject jo = (JObject)JsonConvert.DeserializeObject(temp);
            string  msg;

            Models.Apartment apartment = new Models.Apartment((int)jo["id"], jo["num"].ToString(), jo["name"].ToString(), jo["note"].ToString());
            return(Models.BLL.ApartManage.Update(apartment, out msg) ? JsonConvert.SerializeObject(new Packet(200, "修改成功")) : JsonConvert.SerializeObject(new Packet(202, msg)));
        }
Exemplo n.º 2
0
        public static string AddRecord(string apt)
        {
            string[] strArray = apt.Split(';');
            string   msg;

            Models.Apartment apartment1 = new Models.Apartment(strArray[2], strArray[3], strArray[4]);
            return(Models.BLL.ApartManage.Add(apartment1, out msg) ? JsonConvert.SerializeObject(new Packet(200, "插入成功")) : JsonConvert.SerializeObject(new Packet(203, msg)));
        }
Exemplo n.º 3
0
        public static void fillApartments()
        {
            using (var addData = new ApartmentDB())
            {
                //Add apartments to table
                var apartment = new Models.Apartment
                {
                    ID = 1,
                    Apartmentnumber = "0101",
                    IDDoor          = 1
                };
                addData.Apartments.Add(apartment);


                apartment = new Models.Apartment
                {
                    ID = 2,
                    Apartmentnumber = "0102",
                    IDDoor          = 3
                };
                addData.Apartments.Add(apartment);

                apartment = new Models.Apartment
                {
                    ID = 3,
                    Apartmentnumber = "0103",
                    IDDoor          = 5
                };
                addData.Apartments.Add(apartment);

                apartment = new Models.Apartment
                {
                    ID = 4,
                    Apartmentnumber = "0201",
                    IDDoor          = 7
                };
                addData.Apartments.Add(apartment);

                apartment = new Models.Apartment
                {
                    ID = 5,
                    Apartmentnumber = "0202",
                    IDDoor          = 9
                };
                addData.Apartments.Add(apartment);

                apartment = new Models.Apartment
                {
                    ID = 6,
                    Apartmentnumber = "0301",
                    IDDoor          = 11
                };
                addData.Apartments.Add(apartment);

                apartment = new Models.Apartment
                {
                    ID = 7,
                    Apartmentnumber = "0302",
                    IDDoor          = 13
                };
                addData.Apartments.Add(apartment);


                apartment = new Models.Apartment
                {
                    ID = 8,
                    Apartmentnumber = "Entrance",
                    IDDoor          = 15
                };
                addData.Apartments.Add(apartment);


                apartment = new Models.Apartment
                {
                    ID = 9,
                    Apartmentnumber = "Garbageroom",
                    IDDoor          = 16
                };
                addData.Apartments.Add(apartment);


                apartment = new Models.Apartment
                {
                    ID = 10,
                    Apartmentnumber = "Laundryroom",
                    IDDoor          = 17
                };
                addData.Apartments.Add(apartment);


                apartment = new Models.Apartment
                {
                    ID = 11,
                    Apartmentnumber = "Janitor",
                    IDDoor          = 18
                };
                addData.Apartments.Add(apartment);

                addData.SaveChanges();

                //Apartments added to table
            }
        }