public List<UserDataObject> RetrieveAllUsers(string Fid)
        {
            try
            {
                List<UserDataObject> listOut = new List<UserDataObject>();

                List<DataObject.UserDataObject> listReceived = BusinessLayer.Users.RetrieveAllUser(Fid);
                foreach (var item in listReceived)
                {
                    UserDataObject Data = new UserDataObject();
                    Data.AutoId = item.AutoId;
                    Data.City = item.City;
                    Data.Dob = item.Dob;
                    Data.EmailId = item.EmailId;
                    Data.Name = item.Name;
                    Data.PhoneNumber = item.PhoneNumber;
                    Data.Uid = item.Uid;
                    listOut.Add(Data);
                }
                return listOut;
            }
            catch (Exception ex)
            {
                MyCustomErrorDetail Error = new MyCustomErrorDetail("Unexpected Error caused by " + ex.Source, ex.Message);
                throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.InternalServerError);
            }
        }
 public RegisterDataObject RetrievePassword(DataObject.RegisterDataObject userData)
 {
     try
     {
         DataObject.RegisterDataObject Password = BusinessLayer.Accounts.Retrieve(userData);
         if (string.IsNullOrEmpty(Password.Password))
         {
             return new RegisterDataObject();
         }
         else
         {
             RegisterDataObject Data = new RegisterDataObject();
             Data.AutoId = Password.AutoId;
             Data.ConfirmPassword = Password.ConfirmPassword;
             Data.EmailId = Password.EmailId;
             Data.FullName = Password.FullName;
             Data.Guid = Password.Guid;
             Data.Password = Password.Password;
             Data.UserName = Password.UserName;
             return Data;
         }
     }
     catch (Exception ex)
     {
         MyCustomErrorDetail Error = new MyCustomErrorDetail("Unexpected Error caused by " + ex.Source, ex.Message);
         throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.InternalServerError);
     }
 }
        public UserDataObject RetrieveUser(string userId)
        {
            try
            {
                DataObject.UserDataObject UserData = BusinessLayer.Users.RetrieveUser(userId);
                if (string.IsNullOrEmpty(UserData.AutoId))
                {
                    MyCustomErrorDetail Error = new MyCustomErrorDetail("No user found", "No User with such id was in the database");
                    throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.NotFound);
                }
                else
                {
                    UserDataObject Data = new UserDataObject();
                    Data.AutoId = UserData.AutoId;
                    Data.City = UserData.City;
                    Data.Dob = UserData.Dob;
                    Data.EmailId = UserData.EmailId;
                    Data.Name = UserData.Name;
                    Data.PhoneNumber = UserData.PhoneNumber;
                    Data.Uid = UserData.Uid;

                    return Data;
                }
            }
            catch (Exception ex)
            {
                MyCustomErrorDetail Error = new MyCustomErrorDetail("Unexpected Error caused by " + ex.Source, ex.Message);
                throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.InternalServerError);
            }
        }
        private bool Validar()
        {
            try
            {
                // http://localhost:29231/SolicitudServicio.svc/SolicitudServicio/Buscar/?idMotivo=1&idComercio=1&idModelo=1
                HttpWebRequest req2 = (HttpWebRequest)WebRequest.Create(
                    "http://localhost:29231/SolicitudServicio.svc/ObtenerPorCampos?idMotivo=" + ddlMotSol.SelectedValue + "&idComercio=" + ddlCli.SelectedValue + "&idModelo=" + ddlTerSol.SelectedValue);
                req2.Method = "GET";
                HttpWebResponse      res2              = (HttpWebResponse)req2.GetResponse();
                StreamReader         reader2           = new StreamReader(res2.GetResponseStream());
                string               solicitudJson2    = reader2.ReadToEnd();
                JavaScriptSerializer js                = new JavaScriptSerializer();
                SolicitudServicioDTO solicitudObtenido = js.Deserialize <SolicitudServicioDTO>(solicitudJson2);
            }
            catch (WebException e)
            {
                HttpStatusCode       code        = ((HttpWebResponse)e.Response).StatusCode;
                string               message     = ((HttpWebResponse)e.Response).StatusDescription;
                StreamReader         reader      = new StreamReader(e.Response.GetResponseStream());
                string               error       = reader.ReadToEnd();
                JavaScriptSerializer js          = new JavaScriptSerializer();
                MyCustomErrorDetail  Observacion = js.Deserialize <MyCustomErrorDetail>(error);
                string               sError      = "";
                sError = Observacion.ErrorDetails;

                Page.ClientScript.RegisterStartupScript(this.GetType(), "showSaveMessageError", "<script language='javascript'>alert('" + sError + "');</script>");
            }

            return(false);
        }
 public string Register(DataObject.RegisterDataObject accountData)
 {
     try
     {
         BusinessLayer.Accounts.Register(accountData);
         return "Success";
     }
     catch (Exception ex)
     {
         MyCustomErrorDetail Error = new MyCustomErrorDetail("Error in Registering",ex.Message);
         throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.InternalServerError);
     }
 }
예제 #6
0
        public SolicitudServicioDTO ObtenerPorCampos(int idMotivo, int idComercio, int idModelo)
        {
            SolicitudServicioDTO sol = SolicitudServicioDAO.GetByFields(idMotivo, idComercio, idModelo);

            if (sol != null)
            {
                MyCustomErrorDetail customError = new MyCustomErrorDetail();
                customError.ErrorDetails = "SolicitudServicio existe";
                customError.ErrorInfo    = "SolicitudServicio existe. Para una nuevo registro, los campo motivo, comercio and modelo no deben estar registrado.";
                throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.Found);
            }
            return(sol);
        }
 public string AddUser(DataObject.UserDataObject userData)
 {
     try
     {
         BusinessLayer.Users.CreateUser(userData);
         return "Success";
     }
     catch (Exception ex)
     {
         MyCustomErrorDetail Error = new MyCustomErrorDetail("Error in Adding User", ex.Message);
         throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.InternalServerError);
     }
 } 
예제 #8
0
        //public List<Entities.SolicitudServicioDTO> ListarBandeja(string fechaDesde, string fechaHasta, string estado, int empresaId)
        //{
        //    return SolicitudServicioDAO.GetBandeja( fechaDesde,   fechaHasta,   estado,   empresaId);
        //}

        public Entities.SolicitudServicioDTO Obtener(int id)
        {
            SolicitudServicioDTO sol = SolicitudServicioDAO.Get(id);

            if (sol == null)
            {
                MyCustomErrorDetail customError = new MyCustomErrorDetail();
                customError.ErrorDetails = "SolicitudServicio no existe";
                customError.ErrorInfo    = "No existe SolicitudServicio con id.";

                throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound);
            }
            return(sol);
        }
예제 #9
0
 //for inserting distance from front-end json to database
 public void InsertDistanceInfo(List <Distance_Table> distance_info)
 {
     if (distance_info.Count() != 0)
     {
         EntitiesContext ec = new EntitiesContext();
         ec.Distances.AddRange(distance_info);
         ec.SaveChanges();
     }
     else
     {
         MyCustomErrorDetail customError = new MyCustomErrorDetail("Distance list not found",
                                                                   "Please check whether the list is successfully send!");
         throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound);
     }
 }
예제 #10
0
 public void InsertOptimalRoute_Config(ConfigOptimalRoute configData)
 {
     if (configData != null)
     {
         EntitiesContext ec = new EntitiesContext();
         ec.OptimalRoute_Config.Add(configData);
         ec.SaveChanges();
     }
     else
     {
         MyCustomErrorDetail customError = new MyCustomErrorDetail("Optimal Route Configuration not found",
                                                                   "Please check wheteher config properties with proper input type is provided!");
         throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound);
     }
 }
예제 #11
0
 public void InsertCustomer(Customer customer)
 {
     if (customer != null)
     {
         EntitiesContext ec = new EntitiesContext();
         ec.Customers.Add(customer);
         ec.SaveChanges();
     }
     else
     {
         MyCustomErrorDetail customError = new MyCustomErrorDetail("Correct customer details not found",
                                                                   "Please check all the customer fields entered are of correct type!");
         throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound);
     }
 }
예제 #12
0
        public IEnumerable <Customer> GetCustomer()
        {
            List <Customer> customerList = new List <Customer>();
            EntitiesContext ec           = new EntitiesContext();

            customerList = (from cust in ec.Customers
                            orderby cust.Id
                            select cust).Skip(1).Take(7).ToList();

            if (customerList.Count() == 0)
            {
                MyCustomErrorDetail customError = new MyCustomErrorDetail("Customers not found",
                                                                          "No customer list exists in the database! Please check the Database First!");
                throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound);
            }
            return(customerList);
        }
예제 #13
0
        public IEnumerable <ConfigOptimalRoute> GetOptimalRoute_Config()
        {
            List <ConfigOptimalRoute> configData = new List <ConfigOptimalRoute>();
            EntitiesContext           ec         = new EntitiesContext();

            configData = (from cust in ec.OptimalRoute_Config
                          orderby cust.Unload_Time
                          select cust).ToList();
            if (configData.Count == 0)
            {
                MyCustomErrorDetail customError = new MyCustomErrorDetail("Configuration data not found",
                                                                          "No configuration properties  list exists in the database! Please check the Database First!");
                throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound);
            }

            return(configData);
        }
예제 #14
0
        public UserProfile AuthenticateUser(string email, string password)
        {
            UserProfile user;

            try
            {
                user = SqlHelper.AuthenticateUser(email, password);
            }
            catch (Exception e)
            {
                this.log.Error(e);
                //return null;
                MyCustomErrorDetail customError = new MyCustomErrorDetail("Error",
                                                                          "We are unable to connect to our services. Please retry later.");
                throw new System.ServiceModel.Web.WebFaultException <MyCustomErrorDetail>(customError, System.Net.HttpStatusCode.InternalServerError);
            }
            return(user);
        }
예제 #15
0
 public string DeleteUser(string uid)
 {
     _log.Info("DeleteUser Entered");
     _log.Debug("Parameter id:" + uid);
     try
     {
         BusinessLayer.Contacts.DeleteContact(uid);
         _log.Debug("Result : Success");
         return "Success";
     }
     catch (Exception ex)
     {
         _log.Error("Error in Deleting User :"******"Error in Deleting User", ex.Message);
         throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.InternalServerError);
     }
     finally
     {
         _log.Info("DeleteUser Exited");
     }
 }
예제 #16
0
        public string AddUser(Contact userData)
        {
            _log.Info("AddUser Entered");
            _log.Debug("userData :" + JsonConvert.SerializeObject(userData, Formatting.Indented));

            try
            {
                BusinessLayer.Contacts.CreateContact(userData);
                _log.Debug("Result : Success");
                return "Success";
            }
            catch (Exception ex)
            {
                MyCustomErrorDetail Error = new MyCustomErrorDetail("Error in Adding User", ex.Message);
                _log.Error("Error in Adding User" + ex.Message);
                throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.InternalServerError);
            }
            finally
            {
                _log.Info("AddUser Exited");
            }
        }
예제 #17
0
 public void UpdateCustomer(Customer customer)
 {
     if (customer != null)
     {
         EntitiesContext ec = new EntitiesContext();
         var             c  = (from cust in ec.Customers
                               where cust.Id == customer.Id
                               select cust).First();
         c.Name        = customer.Name;
         c.PostCode    = customer.PostCode;
         c.HouseNumber = customer.HouseNumber;
         c.Street      = customer.Street;
         c.Telephone   = customer.Telephone;
         c.Fax         = customer.Fax;
         c.City        = customer.City;
         ec.SaveChanges();
     }
     else
     {
         MyCustomErrorDetail customError = new MyCustomErrorDetail("Correct customer details not provided",
                                                                   "Please check all the customer fields entered are of correct type!");
         throw new WebFaultException <MyCustomErrorDetail>(customError, HttpStatusCode.NotFound);
     }
 }
예제 #18
0
        public List<Contact> RetrieveAllUsers(string AccountRelatedId)
        {
            _log.Info("RetrieveAllUsers Entered");
            _log.Debug("Parameter id:" + AccountRelatedId);
            try
            {
                List<Contact> ListOut = BusinessLayer.Contacts.RetrieveAllContact(AccountRelatedId);

                _log.Debug("Result :" + JsonConvert.SerializeObject(ListOut, Formatting.Indented));
                return ListOut;
            }
            catch (Exception ex)
            {
                _log.Error("Unexpected Error :" + ex.Message);
                MyCustomErrorDetail Error = new MyCustomErrorDetail("Unexpected Error", ex.Message);
                throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.InternalServerError);
            }
            finally
            {
                _log.Info("RetrieveAllUsers Exited");
            }
        }
예제 #19
0
        public Contact RetrieveUser(string userId)
        {
            _log.Info("RetrieveUser Entered");
            _log.Debug("Parameter :" + userId);
            try
            {
                Contact Data = BusinessLayer.Contacts.RetrieveContact(userId);

                if (string.IsNullOrEmpty(Data.AutoId))
                {
                    _log.Error("No User with such id was in the database");
                    MyCustomErrorDetail Error = new MyCustomErrorDetail("No user found", "No User with such id was in the database");
                    throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.NotFound);
                }
                else
                {
                    _log.Debug("Result :" + JsonConvert.SerializeObject(Data, Formatting.Indented));
                    return Data;
                }
            }
            catch (Exception ex)
            {
                _log.Error("Unexpected Error :" + ex.Message);
                MyCustomErrorDetail Error = new MyCustomErrorDetail("Unexpected Error", ex.Message);
                throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.InternalServerError);
            }
            finally
            {
                _log.Info("RetrieveUser Exited");
            }
        }
 public string DeleteUser(string uid)
 {
     try
     {
         BusinessLayer.Users.DeleteUser(uid);
         return "Success";
     }
     catch (Exception ex)
     {
         MyCustomErrorDetail Error = new MyCustomErrorDetail("Error in Updating User", ex.Message);
         throw new WebFaultException<MyCustomErrorDetail>(Error, System.Net.HttpStatusCode.InternalServerError);
     }
 }