コード例 #1
0
        public IHttpActionResult PostElectricity([FromBody] string electricity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ElectricityModel sm = JsonConvert.DeserializeObject <ElectricityModel>(electricity);
            EMI emi             = new EMI()
            {
                EmisCode     = sm.Generalmodel.Emi.EmisCode,
                NameOfSchool = sm.Generalmodel.Emi.NameOfSchool,
                CreatedOn    = DateTime.UtcNow,
                ModifiedOn   = DateTime.UtcNow
            };

            db.EMIS.Add(emi);
            db.SaveChanges();
            Comment c = new Comment()
            {
                Entity     = sm.Generalmodel.Comment.Entity,
                SurveyID   = sm.Generalmodel.Comment.SurveyID,
                Section    = sm.Generalmodel.Comment.Section,
                CreatedOn  = DateTime.UtcNow,
                ModifiedOn = DateTime.UtcNow,
                Comments   = sm.Generalmodel.Comment.Comments
            };

            db.Comments.Add(c);
            db.SaveChanges();
            SpecialFacility sf = new SpecialFacility()
            {
                Entity     = sm.Generalmodel.Specialfacility.Entity,
                SurveyID   = sm.Generalmodel.Specialfacility.SurveyID,
                Section    = sm.Generalmodel.Specialfacility.Section,
                CreatedOn  = DateTime.UtcNow,
                ModifiedOn = DateTime.UtcNow,
                AnyFacilitiesForDisableStudents = sm.Generalmodel.Specialfacility.AnyFacilitiesForDisableStudents,
                Description = sm.Generalmodel.Specialfacility.Description
            };

            db.SpecialFacilities.Add(sf);
            db.SaveChanges();
            List <Picture> res = sm.Generalmodel.Img.Select(x => new Picture
            {
                Entity     = x.Entity,
                SurveyID   = x.SurveyID,
                Section    = x.Section,
                CreatedOn  = DateTime.UtcNow,
                ModifiedOn = DateTime.UtcNow,
                Picture1   = x.Picture1
            }).ToList();

            db.Pictures.AddRange(res);
            db.SaveChanges();



            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
コード例 #2
0
        public static ElectricityModel GetElectricityData()
        {
            ElectricityModel model = new ElectricityModel();
            ElectricityItem  item  = new ElectricityItem();

            item.Name  = "Account3";
            item.Price = 33.5m;
            item.Type  = BuildingType.House;

            model.Items.Add(item);

            item       = new ElectricityItem();
            item.Name  = "Account4";
            item.Price = 34.2m;
            item.Type  = BuildingType.Flat;

            model.Items.Add(item);

            item       = new ElectricityItem();
            item.Name  = "Account5";
            item.Price = 44.1m;
            item.Type  = BuildingType.Other;
            model.Items.Add(item);

            return(model);
        }
コード例 #3
0
        public IHttpActionResult GetElectricity()
        {
            ElectricityModel model = Helper.GetElectricityData();

            return(Ok(model));
        }