Пример #1
0
        public UserLogin Login(string userName, string password /*, out UserLoginMessage msg*/)
        {
            try
            {
                using (var context = new CellularModelDB())
                {
                    UserLogin tmp;
                    tmp = context.UserLoginsTable.SingleOrDefault((u) => u.UserName == userName && u.Password == password);
                    if (tmp != null)
                    {
                        //msg = UserLoginMessage.userExist;
                        return(tmp);
                    }
                    else
                    {
                        tmp = context.UserLoginsTable.SingleOrDefault((u) => u.UserName == userName);
                        //if (tmp != null)
                        //   // msg = UserLoginMessage.worngPassword;
                        //else
                        // msg = UserLoginMessage.userNotExist;

                        return(null);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Log.WriteToLog("Failed connect to data base" + Environment.NewLine + DateTime.Now.ToString() + Environment.NewLine + "Exception details: " + e.ToString());
                throw new Exception();
            }
        }
Пример #2
0
        private bool CheckLineNumber(string lineNumber)
        {
            try
            {
                using (var context = new CellularModelDB())
                {
                    Line tmp = context.LinesTable.FirstOrDefault((l) => l.LineNumber == lineNumber);
                    return(tmp == null ? true : false);
                }
            }

            catch (Exception e)
            {
                Log(e);
                throw new DbFaildConnncetException("Failed connect to data base");
            }
        }
Пример #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);


            var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;

            json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.All;

            //create db if model chenge
            using (var context = new CellularModelDB())
            {
                List <Client> clients = context.ClientsTable.ToList();
            }
        }
Пример #4
0
        public ICollection <Call> IssuingInvoice(int clientId)
        {
            try
            {
                using (var context = new CellularModelDB())
                {
                    //get all client lines
                    List <Line> liens = context.LinesTable.Where((l) => l.Client.ClientID == clientId).ToList();
                    List <Call> calls = new List <Call>();



                    return(calls);
                }
            }
            catch (Exception e)
            {
                Logger.Log.WriteToLog("Failed connect to data base" + Environment.NewLine + DateTime.Now.ToString() + Environment.NewLine + "Exception details: " + e.ToString());
            }
        }
 public Client DeleteClient(int id)
 {
     try
     {
         using (var contex = new CellularModelDB())
         {
             Client tmp = contex.ClientsTable.FirstOrDefault((c) => c.ClientID == id);
             foreach (var line in tmp.Lines)
             {
                 line.IsActive = false;
             }
             return(tmp);
         }
     }
     catch (Exception e)
     {
         Log(e);
         throw new DbFaildConnncetException("Failed connect to data base");
     }
 }
Пример #6
0
        public Line DeleteLine(string lineNumber)
        {
            try
            {
                using (var context = new CellularModelDB())
                {
                    Line tmp = context.LinesTable.FirstOrDefault((l) => l.LineNumber == lineNumber);
                    if (tmp == null)
                    {
                        throw new EntityNotExistsException("Line number not exists");
                    }

                    tmp.IsActive = false;
                    context.SaveChanges();
                    return(tmp);
                }
            }
            catch (Exception e)
            {
                Log(e);
                throw new DbFaildConnncetException("Failed connect to data base");
            }
        }