public JsonResult GetServiceTypes() { List <TServiceType> all = null; using (Entities1 dc = new Entities1()) { dc.Configuration.ProxyCreationEnabled = false; var serviceTypes = from a in dc.TServiceTypes select new { a }; if (serviceTypes != null) { all = new List <TServiceType>(); foreach (var i in serviceTypes) { TServiceType con = i.a; all.Add(con); } } } return(new JsonResult { Data = all, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
/// <summary> /// Get the registered type /// </summary> /// <typeparam name="TServiceType"></typeparam> /// <returns></returns> public static TServiceType Resolve <TServiceType>() { TServiceType svc = default(TServiceType); Type t = typeof(TServiceType); svc = (TServiceType)Resolve(t); return(svc); }
/// <summary> /// Get service from collection. /// </summary> /// <typeparam name="TServiceType">Service type.</typeparam> /// <returns>Service instance.</returns> public static TServiceType Get <TServiceType>() where TServiceType : class { TServiceType result = default(TServiceType); if (LibraryContainer.Current != null) { result = LibraryContainer.Current.Resolve <TServiceType>(); } return(result); }
public TServiceType GetRequiredService <TServiceType>() { TServiceType service = GetService <TServiceType>(); if (service == null) { throw FxTrace.Exception.AsError(new NotSupportedException( string.Format(CultureInfo.CurrentCulture, Resources.Error_RequiredService, typeof(TServiceType).FullName))); } return(service); }
public TServiceType GetRequiredService <TServiceType>() { TServiceType service = this.GetService <TServiceType>(); if ((object)service == null) { throw new NotSupportedException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Resources.Error_RequiredService, new object[1] { (object)typeof(TServiceType).FullName })); } return(service); }
//Get Service Type by ID public TServiceType GetServiceType(int intServiceTypeID) { TServiceType serviceTypes = null; using (Entities1 dc = new Entities1()) { var v = (from a in dc.TServiceTypes where a.intServiceTypeID.Equals(intServiceTypeID) select new { a }).FirstOrDefault(); if (v != null) { serviceTypes = v.a; } return(serviceTypes); } }
public ActionResult Save(TServiceType c) { string message = ""; bool status = false; if (ModelState.IsValid) { using (Entities1 dc = new Entities1()) { if (c.intServiceTypeID > 0) { var v = dc.TServiceTypes.Where(a => a.intServiceTypeID.Equals(c.intServiceTypeID)).FirstOrDefault(); if (v != null) { v.strServiceType = c.strServiceType; } else { return(HttpNotFound()); } } else { dc.TServiceTypes.Add(c); } dc.SaveChanges(); status = true; message = "Data Is Successfully Saved."; } } else { message = "Error! Please try again."; } return(new JsonResult { Data = new { status = status, message = message } }); }