public int SaveMuteAuth(muteAuthorityItem muteAuth) { mc = new MuteAuthController(); int result = mc.SaveMuteAuth(muteAuth); return(result); }
public muteAuthorityItem[] GetMuteAuthsById(string id) { try { logger.LogMethod("jo", "GetMuteAuthsById", "Enter"); List <muteAuthorityItem> list = new List <muteAuthorityItem>(); key = id.ToString() + "GetMuteAuthsById"; if (CachingConfig.CachingEnabled) { list = (List <muteAuthorityItem>)WCFCache.Current[key]; if (list != null) { logger.LogMethod("jo", "GetMuteAuthsById", "Cache found"); return(list.ToArray()); } } list = new List <muteAuthorityItem>(); context = new SocialCopsEntities(); int mid = Convert.ToInt32(id); List <MuteAuthority> muteAuths = (from a in context.MuteAuthorities where a.muteAuthId == mid orderby a.date descending select a).ToList(); foreach (MuteAuthority auth in muteAuths) { muteAuthorityItem temp = new muteAuthorityItem(); temp.muteAuthId = auth.muteAuthId; temp.muteAuthName = auth.muteAuthName; temp.muteAuthAddress = auth.muteAuthAddress; temp.city = auth.city; temp.state = auth.state; temp.country = auth.country; temp.email = auth.email; temp.phone = auth.phone; temp.latitude = (float)auth.latitude; temp.longitude = (float)auth.longitude; temp.website = auth.website; temp.pic = auth.pic; temp.date = (DateTime)auth.date; temp.flag = (int)auth.flag; temp.pincode = auth.pincode; list.Add(temp); } Cache.Cache.AddToCache(key, list); logger.LogMethod("jo", "GetMuteAuthsById", "Exit"); return(list.ToArray()); } catch (Exception ex) { error.ErrorDetails = ex.Message.ToString(); error.ErrorMessage = "Something happened. Sorry."; error.Result = false; logger.LogMethod("jo", "GetMuteAuthsById", ex.Message.ToString()); throw new FaultException <Bug>(error, ex.Message.ToString()); } }
public int SaveMuteAuth(muteAuthorityItem muteAuth) { try { logger.LogMethod("jo", "SaveMuteAuth", "Enter", null); context = new SocialCopsEntities(); MuteAuthority temp = new MuteAuthority(); List <MuteAuthority> muteAuths = (from m in context.MuteAuthorities where m.email == muteAuth.email select m).ToList(); if (muteAuths.Count > 0) { logger.LogMethod("jo", "SaveMuteAuth", "Invalid Sign-up. Email address already exists."); error.ErrorDetails = "Email address already exists."; error.Result = false; error.ErrorMessage = "Email address already exists. Cannot register again."; throw new WebFaultException <Bug>(error, System.Net.HttpStatusCode.NotAcceptable); } temp.muteAuthName = muteAuth.muteAuthName; temp.muteAuthAddress = muteAuth.muteAuthAddress; temp.city = muteAuth.city; temp.state = muteAuth.state; temp.country = muteAuth.country; temp.email = muteAuth.email; temp.phone = muteAuth.phone; temp.latitude = muteAuth.latitude; temp.longitude = muteAuth.longitude; temp.website = muteAuth.website; temp.pic = muteAuth.pic; temp.date = System.DateTime.Now; temp.flag = muteAuth.flag; temp.pincode = muteAuth.pincode; context.MuteAuthorities.Add(temp); context.SaveChanges(); logger.LogMethod("jo", "SaveMuteAuth", "Exit", null); //userItem u = (userItem)context.Entry(temp); return(temp.muteAuthId); } catch (WebFaultException <Bug> ex) { throw; } catch (Exception ex) { error.Result = false; error.ErrorMessage = "unforeseen error occured. Please try later."; error.ErrorDetails = ex.ToString(); throw new FaultException <Bug>(error, ex.ToString()); } }