public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (objectType == typeof(Certification)) { JObject obj = serializer.Deserialize <JToken>(reader) as JObject; if (obj != null) { CertificationTypes certificationType = CertificationTypes.FairTrade; if (obj["CerificationType"] != null && ((JValue)obj["CerificationType"]).Value != null) { certificationType = (CertificationTypes)Enum.Parse(typeof(CertificationTypes), ((JValue)obj["CerificationType"]).Value.ToString()); } var certification = ObjectFactory.CreateCertification(certificationType, null); certification.ReadJson(obj); return(certification); } else { return(null); } } else { return(null); } }
public async void LoadComboBoxes(object e) { var certificationTypes = await GetData.CertificationQueryAsync(); foreach (CertificationModel certification in certificationTypes) { CertificationTypes.Add(certification); } var restrictionTypes = await GetData.RestrictionQueryAsync(); foreach (RestrictionModel restrictionType in restrictionTypes) { RestrictionTypes.Add(restrictionType); } var departments = await GetData.DepartmentQueryAsync(); foreach (DepartmentModel department in departments) { Departments.Add(department); } var jobTitles = await GetData.JobTitleQueryAsync(); foreach (JobTitleModel jobTitle in jobTitles) { JobTitles.Add(jobTitle); } }
public Certification Add(CertificationTypes type) { Certification certification = null; switch (type) { case CertificationTypes.FairTrade: certification = new FairTrade(this); break; case CertificationTypes.Organic: certification = new Organic(this); break; case CertificationTypes.UTZ: certification = new UTZ(this); break; } if (certification != null) { certification.ObjectState = ObjectStates.Added; _certifications.Add(certification); } return(certification); }
public IActionResult DeleteCertificationType(int id) { CertificationTypes type = _db.CertificationTypes.Find(id); _db.CertificationTypes.Remove(type); _db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult EditCertificationType(CertificationTypes type) { CertificationTypes updateType = _db.CertificationTypes.SingleOrDefault(t => t.CertificationTypeId == type.CertificationTypeId); if (updateType != null) { updateType.Name = type.Name; _db.SaveChanges(); } return(RedirectToAction("Index")); }
public static Certification CreateCertification(CertificationTypes certificationType, DCAnalyticsObject parent) { Certification certification = null; switch (certificationType) { case CertificationTypes.FairTrade: certification = new FairTrade(parent); break; case CertificationTypes.Organic: certification = new Organic(parent); break; case CertificationTypes.UTZ: certification = new UTZ(parent); break; } return(certification); }
public IActionResult EditCertificationTypeView(int id) { CertificationTypes type = _db.CertificationTypes.Find(id); return(View(type)); }
public IActionResult AddCertificationType(CertificationTypes type) { _db.CertificationTypes.Add(type); _db.SaveChanges(); return(RedirectToAction("Index")); }