示例#1
0
        public dynamic Post()
        {
            WSC2019_SS1Entities db = new WSC2019_SS1Entities();

            return(db.AssetGroups.Select(x => new {
                ID = x.ID,
                Name = x.Name
            }));
        }
示例#2
0
        public dynamic Post()
        {
            WSC2019_SS1Entities db = new WSC2019_SS1Entities();

            return(db.Employees.Select(x => new {
                ID = x.ID,
                FirstName = x.FirstName,
                LastName = x.LastName,
                Phone = x.Phone
            }));
        }
示例#3
0
        public dynamic Post()
        {
            WSC2019_SS1Entities db = new WSC2019_SS1Entities();

            return(db.Assets.Select(x => new
            {
                ID = x.ID,
                AssetSN = x.AssetSN,
                AssetName = x.AssetName,
                DepartmentLocationID = x.DepartmentLocationID,
                EmployeeID = x.EmployeeID,
                AssetGroupID = x.AssetGroupID,
                Description = x.Description,
                WarrantyDate = x.WarrantyDate,
                DepartmentID = x.DepartmentLocation.DepartmentID,
                DepartmentName = x.DepartmentLocation.Department.Name,
                LocationID = x.DepartmentLocation.LocationID,
                LocationName = x.DepartmentLocation.Location.Name
            }));
        }
        public dynamic Post([FromBody] object json2)
        {
            try
            {
                Dictionary <string, object> json = JsonConvert.DeserializeObject <Dictionary <string, object> >(json2.ToString());
                db = new WSC2019_SS1Entities();
                Models.Asset asset = new Models.Asset();
                asset.AssetName    = json["AssetName"].ToString();
                asset.AssetSN      = json["AssetSN"].ToString();
                asset.AssetGroupID = Convert.ToInt32(json["AssetGroupID"]);
                asset.Description  = json["Description"].ToString();
                asset.WarrantyDate = Convert.ToInt32(json["WarrantyDate"]);
                asset.EmployeeID   = Convert.ToInt32(json["EmployeeID"]);
                int locationid        = Convert.ToInt32(json["LocationID"]);
                int departmentid      = Convert.ToInt32(json["DepartmentID"]);
                DepartmentLocation dl = db.DepartmentLocations.Where(x => x.LocationID == locationid && x.DepartmentID == departmentid).SingleOrDefault();
                if (dl == null)
                {
                    dl.DepartmentID = departmentid;
                    dl.LocationID   = locationid;
                    dl.StartDate    = DateTime.Now;
                    db.DepartmentLocations.Add(dl);
                    db.SaveChanges();
                    dl = db.DepartmentLocations.Where(x => x.LocationID == locationid && x.DepartmentID == departmentid).SingleOrDefault();
                }
                asset.DepartmentLocationID = dl.ID;

                db.Assets.Add(asset);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            return("ok");
        }
        public dynamic Post()
        {
            WSC2019_SS1Entities db = new WSC2019_SS1Entities();

            return(db.Departments.Select(x => new { ID = x.ID, Name = x.Name }));
        }