public async Task <HttpResponseMessage> GetCurrentProfileAsync() { Result <Profile> result = new Result <Profile>(); using (FlightPostponedContext context = new FlightPostponedContext()) { try { var username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;// HttpContext.Current.User.Identity.Name; UserLogic user = new UserLogic(new Dal.Repository.UserRepository(context)); var profileuser = await user.GetProfile(username); result.IsErr = false; result.Model = new Profile { UserId = profileuser.UserId, FullName = profileuser.FullName, LoginDateYear = DateTime.Now.Year.ToString(), LoginDateMonth = DateTime.Now.Month.ToString(), LoginDateHour = DateTime.Now.ToShortTimeString(), LoginDateNum = DateTime.Now.Day.ToString(), LoginDateDay = "TODO", DomainName = profileuser.DomainName }; } catch (ErrorLogic errlogic) { result.IsErrUnandleException = false; result.IsErr = true; result.TitleErr = errlogic.ErrorTitle; result.ErrDesc = errlogic.Message; ErrorHandle(errlogic); } catch (Exception e) { result.IsErrUnandleException = true; result.IsErr = true; result.TitleErr = ErrorLogic.UNHANDLE_EXCECPTION; result.ErrDesc = e.Message; ErrorHandle(e); } var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <Result>(result, new JsonMediaTypeFormatter(), new MediaTypeWithQualityHeaderValue("application/json")) }; response.Headers.CacheControl = new CacheControlHeaderValue(); response.Headers.CacheControl.NoStore = true; return(response); } }
public async Task <HttpResponseMessage> ChangeStatusPassanners(UserHandle user) { Result <string> result = new Result <string>(); using (FlightPostponedContext context = new FlightPostponedContext()) { try { string channel = "lockedChanges"; var ev = new SessionStatus(); ev.Users = new List <UserHandle> { user }; ev.State = (int)StateSignalREnum.Pub; FlightLogic logic = new FlightLogic(new Dal.Repository.FlightRepository(context), new Dal.Repository.FlightPostponedRepository(context)); var trackid = await logic.PassangersHandleUser(user); //Guid tarckId = Guid.NewGuid(); ev.TrackId = trackid.ToString(); //_context.Clients.Group(SessionStatus.TaskChannel).GetNotify(channel, ev); PulishEvent(channel, ev); result.Model = ev.TrackId; } catch (ErrorLogic errlogic) { result.IsErrUnandleException = false; result.IsErr = true; result.TitleErr = errlogic.ErrorTitle; result.ErrDesc = errlogic.Message; ErrorHandle(errlogic); } catch (Exception e) { result.IsErrUnandleException = true; result.IsErr = true; result.TitleErr = ErrorLogic.UNHANDLE_EXCECPTION; result.ErrDesc = e.Message; ErrorHandle(e); } } var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <Result>(result, new JsonMediaTypeFormatter(), new MediaTypeWithQualityHeaderValue("application/json")) }; response.Headers.CacheControl = new CacheControlHeaderValue(); response.Headers.CacheControl.NoStore = true; return(response); }
public async Task <HttpResponseMessage> CreateNewOrderFlightPostponed(OrderFlightPostponedRequest request) { Result <Guid> result = new Result <Guid>(); using (FlightPostponedContext context = new FlightPostponedContext()) { try { FlightLogic logic = new FlightLogic(new Dal.Repository.FlightRepository(context), new Dal.Repository.FlightPostponedRepository(context)); result.Model = await logic.CreateFlightPostponed(request.Flight, request.HandleBy, request.Passangers); } catch (ErrorLogic errlogic) { result.IsErrUnandleException = false; result.IsErr = true; result.TitleErr = errlogic.ErrorTitle; result.ErrDesc = errlogic.Message; ErrorHandle(errlogic); } catch (Exception e) { result.IsErrUnandleException = true; result.IsErr = true; result.TitleErr = ErrorLogic.UNHANDLE_EXCECPTION; result.ErrDesc = e.Message; ErrorHandle(e); } var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <Result <Guid> >(result, new JsonMediaTypeFormatter(), new MediaTypeWithQualityHeaderValue("application/json")) }; response.Headers.CacheControl = new CacheControlHeaderValue(); response.Headers.CacheControl.NoStore = true; return(response); } }