public IHttpActionResult PutSpecs(string id, Specs specs) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != specs.Class) { return(BadRequest()); } db.Entry(specs).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SpecsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public BusesNewViewModel() { // Initialise bus data Specification = new Specs(); BusMaintenance = new Maintenance(); busService = (App.Current as App).Container.GetService <IBusService>(); PublishAddBusCommand = new RelayCommand( async() => { var messageDialog = new MessageDialog("Are you sure you want to add a new bus?", "Add New Bus"); messageDialog.Commands.Add(new UICommand("Yes", null)); messageDialog.Commands.Add(new UICommand("No", null)); messageDialog.DefaultCommandIndex = 0; messageDialog.CancelCommandIndex = 1; var cmd = await messageDialog.ShowAsync(); if (cmd.Label == "Yes") { busService.AddBus(BusTag, VRN, Specification, BusMaintenance); } ResetBusData(); NavigationService.Navigate(typeof(BusesPage)); }); }
protected override void SetupState() { Specs.InitializeInstance(); Specs.Instance .Add("bogus rule"); }
public Car(string name, Specs specs) { Id = Guid.NewGuid(); Name = name; Specs = specs; }
public IHttpActionResult PostSpecs(Specs specs) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Specs.Add(specs); try { db.SaveChanges(); } catch (DbUpdateException) { if (SpecsExists(specs.Class)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = specs.Class }, specs)); }
public Student(string name, Specs spec, short course, double avGrade) { Name = name; Spec = spec; Course = course; AverageGrade = Math.Round(avGrade, 2); }
private void ProductDetails() { //Load the XML file in XmlDocument. XmlDocument doc1 = new XmlDocument(); doc1.Load(Server.MapPath("~/Data/Detail.xml")); //Loop through the selected Nodes. foreach (XmlNode node in doc1.SelectNodes("/Store/Products/Product")) { ProductDetail productDetail = new ProductDetail { //Fetch the Node values and assign it to Model. Id = node.Attributes.GetNamedItem("id").Value, Title = node["Title"].InnerText, Description = node["Description"].InnerText, Image = node["Image"].InnerText, Availability = node["Availability"].InnerText }; List <Specs> specs = new List <Specs>(); foreach (XmlNode xmlNode in node["Specs"]) { Specs spec = new Specs { Spec = xmlNode.InnerText }; specs.Add(spec); } productDetail.Specs = specs; productDetails.Add(productDetail); } }
/** * Given a Specs object, return a SingleID representing the * special inverse of that ID. If there is no special inverse * then return null. * @return a SingleID or null. Returned object always has * 'filter' field of null. */ private static SingleID SpecsToSpecialInverse(Specs specs) { if (!specs.Source.Equals(ANY, StringComparison.OrdinalIgnoreCase)) { return(null); } string inverseTarget = SPECIAL_INVERSES.Get(new CaseInsensitiveString(specs.Target)); if (inverseTarget != null) { // If the original ID contained "Any-" then make the // special inverse "Any-Foo"; otherwise make it "Foo". // So "Any-NFC" => "Any-NFD" but "NFC" => "NFD". StringBuilder buf = new StringBuilder(); if (specs.Filter != null) { buf.Append(specs.Filter); } if (specs.SawSource) { buf.Append(ANY).Append(TARGET_SEP); } buf.Append(inverseTarget); string basicID = ANY + TARGET_SEP + inverseTarget; if (specs.Variant != null) { buf.Append(VARIANT_SEP).Append(specs.Variant); basicID = basicID + VARIANT_SEP + specs.Variant; } return(new SingleID(buf.ToString(), basicID)); } return(null); }
public Task <Items> UpdateItem(Items item, Specs specs, Model model) { var itemToUpdt = GetItemByModelName(model.Name); var specToUpdt = GetSpecsByName(model.Name); if (specToUpdt != null) { specToUpdt.Description = specs.Description; specToUpdt.Specification = specs.Specification; } ; if (itemToUpdt != null) { itemToUpdt.Availability = item.Availability; itemToUpdt.Price = item.Price; itemToUpdt.Discount = item.Discount; itemToUpdt.Color = item.Color; } ; _context.Specs.Update(specToUpdt); _context.SaveChanges(); _context.Items.Update(itemToUpdt); _context.SaveChanges(); return(null); }
public JsonResult AddItem([FromBody] AdminModel addItem) { /* if(ModelState.IsValid) * {*/ try { var list = new List <string>(); list = addItem.ImageUrls.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList(); List <ImageUrls> imgUrl = new List <ImageUrls>(); foreach (var var in list) { imgUrl.Add(new ImageUrls { Url = var }); } var item = new Items { Availability = addItem.Availibility, Price = addItem.Price, Discount = addItem.Discount, ManuModel = addItem.Manufacturer, Model = addItem.Model, ImageUrls = imgUrl, Color = addItem.Color, ItemTypeSub = new ItemTypeSub { Id = addItem.ItemSubType.Id } }; var model = new Model { ItemDepartment = addItem.ItemDepartment, Name = addItem.ModelName, SpecsId = addItem.Specs, TypeId = addItem.ItemType }; var spec = new Specs { Description = addItem.Specs.Description, Specification = addItem.Specs.Specification }; var addItems = _products.AddItem(item, spec, model); return(Json(addItem.Message = "Item added!"));; } catch { return(Json(addItem.Message = "Adding item failed!")); } /*} * * else { return Json(addItem.Message = "Something went wrong!"); }*/ /* return Json(addItem);*/ }
private void ResetBusData() { Specification = new Specs(); BusMaintenance = new Maintenance(); BusTag = ""; VRN = ""; }
protected override void SetupState() { Specs.InitializeInstance(); Specs.Instance .Add(RULE_MESSAGE) .When(o => o.Number.Length != 10) .Then(o => o.Status = OrderStatus.OnHold); }
public static DbQuery <UserBriefModel> ToDbQuery(this UsersQuery query) { var spec = LinqSpec.For <UserBriefModel>(x => true); if (query.Roles != null && query.Roles.Length > 0) { spec = spec && Specs.HasAtLeastOneRoleFrom(query.Roles); } return(DbQuery.PagedFor <UserBriefModel>().FromClientQuery(query).AndFilterBy(spec)); }
public Item(int itemID, string name, float price, string URL, string desc, Specs specs, int noClick) { this.itemID = itemID; this.name = name; this.price = price; this.URL = URL; this.desc = desc; this.specs = specs; noClick = 0; }
public void AddBus(string busTag, string vrn, Specs specs, Maintenance maintenance) { BusModel busModel = new BusModel() { BusTag = busTag, VRN = vrn, Specification = specs, BusMaintenance = maintenance, AssignedDriver = null }; Buses.Add(busModel); }
public ResultShipSpecs(BattleInfo battleInfo) { Specs = battleInfo.Result?.Friend.Main.Where(s => s.NowHp > 0).Select(ship => ship.Spec).ToArray() ?? new ShipSpec[0]; Names = new NameChecker(Specs); Types = Specs.Select(spec => spec.ShipType).ToArray(); Classes = Specs.Select(spec => spec.ShipClass).ToArray(); Flagship = Specs.FirstOrDefault(); FlagshipType = Types.FirstOrDefault(); }
public IActionResult Put(Specs people) { if (ModelState.IsValid) { db.Update(people); db.SaveChanges(); return(Ok(people)); } return(BadRequest(ModelState)); }
public ReferenceViewModel Clone() { var copied = (ReferenceViewModel)MemberwiseClone(); copied.Additional = new Dictionary <string, object>(Additional); copied.FullNameInDevLangs = new SortedList <string, string>(FullNameInDevLangs); copied.NameInDevLangs = new SortedList <string, string>(NameInDevLangs); copied.NameWithTypeInDevLangs = new SortedList <string, string>(NameWithTypeInDevLangs); copied.Specs = new SortedList <string, List <SpecViewModel> >(Specs.ToDictionary(s => s.Key, s => new List <SpecViewModel>(s.Value))); return(copied); }
public IActionResult Delete(int id) { Specs product = db.Specs.FirstOrDefault(x => x.ID == id); if (product != null) { db.Specs.Remove(product); db.SaveChanges(); } return(Ok(product)); }
public IHttpActionResult GetSpecs(string id) { Specs specs = db.Specs.Find(id); if (specs == null) { return(NotFound()); } return(Ok(specs)); }
/// <summary> /// Returns true if OutputInfo instances are equal /// </summary> /// <param name="other">Instance of OutputInfo to be compared</param> /// <returns>Boolean</returns> public bool Equals(OutputInfo other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Specs == other.Specs || Specs != null && Specs.Equals(other.Specs) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( Logo == other.Logo || Logo != null && Logo.Equals(other.Logo) ) && ( Region == other.Region || Region != null && Region.Equals(other.Region) ) && ( Lang == other.Lang || Lang != null && Lang.Equals(other.Lang) ) && ( AuthType == other.AuthType || AuthType != null && AuthType.Equals(other.AuthType) ) && ( Oauth2 == other.Oauth2 || Oauth2 != null && Oauth2.Equals(other.Oauth2) ) && ( Methods == other.Methods || Methods != null && Methods.Equals(other.Methods) )); }
/* TINKERBOX ----- the tinker box is a static class which I use to easily create * my robots. */ public static GameObject createShape(PrimitiveType type, Specs shape, string name, Color color) { // createShape ----- on the tin GameObject ob = GameObject.CreatePrimitive(type); ob.name = name; ob.transform.position = shape.position; ob.transform.eulerAngles = shape.rotation; ob.transform.localScale = shape.scale; ob.GetComponent <Renderer>().material.color = color; return(ob); }
// TODO what if target null? public virtual IViewModel <T, long> Update(BaseInputModel <T, long> input) { Auth.AuthorizeUpdate(); Logger.Information($"Updating {typeof(T).FullName} Id:{input.Id}."); Validator.Validate(input); var existingObj = Repo.FindOne(Specs.ById <T>(input.Id).And(Auth.GenerateFilterUpdate()), track: true); Mapper.Map(input, existingObj); Repo.Save(); Logger.Information($"Update of {typeof(T).FullName} Id:{input.Id} complete."); return(Mapper.Map <IViewModel <T> >(existingObj)); }
public Task <Specs> AddSpecs(Specs specs) { var specToAdd = new Specs { Description = specs.Description, Specification = specs.Specification, }; _context.Specs.Add(specToAdd); _context.SaveChanges(); return(null); }
public IHttpActionResult DeleteSpecs(string id) { Specs specs = db.Specs.Find(id); if (specs == null) { return(NotFound()); } db.Specs.Remove(specs); db.SaveChanges(); return(Ok(specs)); }
protected override void SetupState() { Specs.InitializeInstance(); Specs.Order.Number = "123456789"; Specs.Instance .Add(RULE1_MESSAGE) .When(o => o.Number.Length != 10) .Then(o => o.Status = OrderStatus.OnHold); Specs.Instance .Add(RULE2_MESSAGE) .When(o => o.Items.Count() == 0) .Then(o => o.Status = OrderStatus.OnHold); }
/** * Parse a filter ID, that is, an ID of the general form * "[f1] s1-t1/v1", with the filters optional, and the variants optional. * @param id the id to be parsed * @param pos INPUT-OUTPUT parameter. On input, the position of * the first character to parse. On output, the position after * the last character parsed. * @return a SingleID object or null if the parse fails */ public static SingleID ParseFilterID(string id, int[] pos) { int start = pos[0]; Specs specs = ParseFilterID(id, pos, true); if (specs == null) { pos[0] = start; return(null); } // Assemble return results SingleID single = SpecsToID(specs, Forward); single.Filter = specs.Filter; return(single); }
public List <SpecificationsModel> GetSpecificationsByProductId(int productId) { var prodCatSpecList = prod_catSpecsRepo.GetProd_CatSpecsByProductId(productId); var catSpecList = catSpecRepo.GetAllByIds(prodCatSpecList.Select(x => x.CategorySpecsId)); var specIds = catSpecList.Select(x => x.SpecId); List <int> specIntIds = new List <int>(); foreach (var s in specIds) { specIntIds.Add(s); } var specList = specsRepo.ReadByIds(specIntIds); var joinedSpecList = from prodCatSpec in prodCatSpecList join catspec in catSpecList on prodCatSpec.CategorySpecsId equals catspec.CategorySpecsId join spec in specList on catspec.SpecId equals spec.SpecId into Specs from Spec in Specs.DefaultIfEmpty() select new { prodCatSpec, catspec, Spec }; var specModelList = new List <SpecificationsModel>(); foreach (var item in joinedSpecList) { specModelList.Add(new SpecificationsModel { SpecId = item.Spec.SpecId, Name = item.Spec.Name, CategorySpecId = item.catspec.CategorySpecsId, Prod_CatSpecId = item.prodCatSpec.Prod_CatSpecId, Value = item.prodCatSpec.SpecValue }); } return(specModelList); }
public int LoadSpecification(string material_id) { Specs.DefaultSpec = GetDefaultSpec(material_id); Console.WriteLine(Specs.DefaultSpec.ToString()); if (Specs.DefaultSpec == null) { return(-1); } List <SpecRecord> records = DataAccess.GetSpecRecords(material_id, "modified_specifications"); foreach (var record in records) { Specs.Add(Factory.CreateSpecFromRecord(record)); } return(0); }
/// <summary> /// Create a new internally-facing <see cref="ServiceV1"/> for the specified database server. /// </summary> /// <param name="server"> /// A <see cref="DatabaseServer"/> representing the target server. /// </param> /// <param name="kubeNamespace"> /// An optional target Kubernetes namespace. /// </param> /// <returns> /// The configured <see cref="ServiceV1"/>. /// </returns> public ServiceV1 InternalService(DatabaseServer server, string kubeNamespace = null) { if (server == null) { throw new ArgumentNullException(nameof(server)); } return(Service( name: Names.BaseName(server), kubeNamespace: kubeNamespace, spec: Specs.InternalService(server), labels: new Dictionary <string, string> { ["k8s-app"] = Names.BaseName(server), ["cloud.dimensiondata.daas.server-id"] = server.Id, ["cloud.dimensiondata.daas.service-type"] = "internal" } )); }
public UpgradeLevel() { specs = new Specs(); prices = new int[(int)UpgradeLevel.Type.Count]; }