Esempio n. 1
0
        public async Task <ActionResult <SimpleResponse> > Login(WebUser user)
        {
            string  hash_pass = PostgreDataBase.hasher(user.pass);
            WebUser user_db   = await
                                _db.users
                                .Where(u => u.pass == hash_pass && u.login == user.login)
                                .FirstOrDefaultAsync();

            if (user_db != null)
            {
                await Authenticate(user_db.login);

                return(new SimpleResponse {
                    message = "Вход выполнен успешно"
                });
            }
            return(new SimpleResponse {
                error = "Пользователь с таким логином и паролем не найден"
            });
        }
Esempio n. 2
0
        public async Task <ActionResult <SimpleResponse> > CreateAccount(WebUser user)
        {
            string  hash_pass = PostgreDataBase.hasher(user.pass);
            WebUser user_db   = await
                                _db.users
                                .Where(u => u.login == user.login)
                                .FirstOrDefaultAsync();

            if (user_db == null)
            {
                await _db.users.AddAsync(
                    new WebUser { login = user.login, pass = hash_pass, email = "" });

                await _db.SaveChangesAsync();
                await Authenticate(user.login);

                return(new SimpleResponse {
                    message = "Аккаунт создан успешно"
                });
            }
            return(new SimpleResponse {
                error = "Пользователь с таким логином или почтой уже существует"
            });
        }
Esempio n. 3
0
 public CreateTicketController(PostgreDataBase db)
 {
     _db = db;
 }
Esempio n. 4
0
 public TicketTypeController(PostgreDataBase db)
 {
     _db = db;
 }
Esempio n. 5
0
        // public Button button {get; set;}

        public TicketResponse ToResponse(PostgreDataBase db)
        {
            ticket = db.tikets
                     .Where(t => t.id == ticket_id).FirstOrDefault();
            ticket.state = db.ticket_states
                           .Where(t => t.id == ticket.state_id).FirstOrDefault();
            ticket.type = db.tiket_types
                          .Where(t => t.id == ticket.type_id).FirstOrDefault();
            ticket.mobile_user = db.mobile_users
                                 .Where(t => t.token == ticket.mobile_token).FirstOrDefault();

            List <TicketHistory> history = db.ticket_historys
                                           .Where(h => h.ticket_id == ticket_id)
                                           .Join(db.ticket_states, h => h.ticket_state_old_id, s => s.id, (h, s) =>
                                                 new TicketHistory
            {
                id                  = h.id,
                date                = h.date,
                ticket_id           = h.ticket_id,
                ticket_state_new_id = h.ticket_state_new_id,
                ticket_state_old_id = h.ticket_state_old_id,
                ticket_state_old    = s
            })
                                           .Join(db.ticket_states, h => h.ticket_state_new_id, s => s.id, (h, s) =>
                                                 new TicketHistory
            {
                id                  = h.id,
                date                = h.date,
                ticket_id           = h.ticket_id,
                ticket_state_new_id = h.ticket_state_new_id,
                ticket_state_new    = s,
                ticket_state_old_id = h.ticket_state_old_id,
                ticket_state_old    = h.ticket_state_old,
            })
                                           .ToList();

            TicketResponse response = new
                                      TicketResponse
            {
                id            = ticket_id,
                date_add      = ticket.date_add,
                state         = ticket.state,
                type          = ticket.type,
                mobile_user   = ticket.mobile_user,
                description   = ticket.description,
                long_         = ticket.long_,
                lat           = ticket.lat,
                dublicates_id = db.ticket_dublicate
                                .Where(d => d.main_tiket == ticket_id)
                                .Select(t => t.tiket)
                                .ToList(),
                photo_id = db.photos
                           .Where(p => p.ticket == ticket_id && !p.mini).Select(p => p.id).ToList(),
                mini_photo_id = db.photos
                                .Where(p => p.ticket == ticket_id && p.mini).Select(p => p.id).ToList(),
                histories = history,
                district  = db.districts.Where(d => d.id == 1).FirstOrDefault(),
            };

            return(response);
        }
Esempio n. 6
0
 public PhotoController(PostgreDataBase db)
 {
     _db = db;
 }
Esempio n. 7
0
 public WebUserController(PostgreDataBase db)
 {
     _db = db;
 }
Esempio n. 8
0
 public ImageController(PostgreDataBase db)
 {
     _db = db;
 }
Esempio n. 9
0
 public DistrictController(PostgreDataBase db)
 {
     _db = db;
 }