Exemplo n.º 1
0
        public muteAuthorityItem[] GetMuteAuths()
        {
            try
            {
                logger.LogMethod("jo", "GetMuteAuths", "Enter");
                List<muteAuthorityItem> list = new List<muteAuthorityItem>();
                key = "GetMuteAuths";
                if (CachingConfig.CachingEnabled)
                {
                    list = (List<muteAuthorityItem>)WCFCache.Current[key];
                    if (list != null)
                    {
                        logger.LogMethod("jo", "GetMuteAuths", "Cache found");
                        return list.ToArray();
                    }
                }
                list = new List<muteAuthorityItem>();
                context = new SocialCopsEntities();
                List<MuteAuthority> muteAuths = (from a
                                         in context.MuteAuthorities
                                         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", "GetMuteAuths", "Exit");
                return list.ToArray();

            }
            catch (Exception ex)
            {
                error.ErrorDetails = ex.Message.ToString();
                error.ErrorMessage = "Something happened. Sorry.";
                error.Result = false;
                logger.LogMethod("jo", "GetMuteAuths", ex.Message.ToString());
                throw new FaultException<Bug>(error, ex.Message.ToString());
            }
        }
Exemplo n.º 2
0
 public int SaveMuteAuth(muteAuthorityItem muteAuth)
 {
     mc = new MuteAuthController();
     int result = mc.SaveMuteAuth(muteAuth);
     return result;
 }
Exemplo n.º 3
0
        public muteAuthorityItem GetCopy()
        {
            muteAuthorityItem copy = (muteAuthorityItem)this.MemberwiseClone();

            return(copy);
        }
Exemplo n.º 4
0
        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());
            }
        }