Exemplo n.º 1
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());
            }
        }
Exemplo n.º 2
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());
            }
        }