Пример #1
0
        public List <RepairView> GetRepairsByTechnicianId(TechnicianView r)
        {
            string URIPart;

            try
            {
                URIPart = URIparts[typeof(RepairView)];
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "NULL vagy kulcs nem létezik hiba", MessageBoxButton.OK);
                return(null);
            }
            var result = httpClient.GetAsync(baseUri + URIPart + "/" + r.Id.ToString()).Result;

            if (!result.IsSuccessStatusCode)
            {
                MessageBox.Show(result.Content.ToString(), result.ReasonPhrase);
            }
            var rawContent     = result.Content.ReadAsStringAsync().Result;
            var parserSettings = new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore, MaxDepth = null
            };
            var obj = JsonConvert.DeserializeObject <List <RepairView> >(rawContent, parserSettings);

            return(obj);
        }
Пример #2
0
        public void UpdateTechnician(TechnicianView tv)
        {
            using var ctx = new WorkshopContext();
            var t = ctx.Technicians.Single(t => t.Id == tv.Id);

            t.Id          = tv.Id;
            t.Name        = tv.Name;
            t.PhoneNumber = tv.PhoneNumber;
            t.UserId      = tv.UserId;
        }
Пример #3
0
        public void AddTechnician(TechnicianView tv)
        {
            using var ctx = new WorkshopContext();
            Technician t = new Technician();

            t.Name        = tv.Name;
            t.PhoneNumber = tv.PhoneNumber;
            t.User        = ctx.Users.Single(u => u.Id == tv.User.Id);
            t.UserId      = t.User.Id;
        }
Пример #4
0
        public bool ValidateUser(UserView u)
        {
            var            valid = workshopClient.ValidateUser(u);
            TechnicianView tech  =
                (from techs in Technicians ?? new List <TechnicianView>()
                 where techs.User.Username == u.Username
                 select techs).FirstOrDefault();

            CurrentTechnician = tech;
            return(valid && tech != null);
        }
Пример #5
0
        public static TechnicianView GetViewModell(Technician t)
        {
            TechnicianView tv = new TechnicianView();

            if (t != null)
            {
                tv.Id                = t.Id;
                tv.Name              = t.Name;
                tv.PhoneNumber       = t.PhoneNumber;
                tv.RepairTechnicians = t.RepairTechnicians?.Select(br => GetViewModell(br)).ToList();
                tv.User              = GetViewModell(t.User);
            }
            return(tv);
        }
Пример #6
0
 public IEnumerable <RepairView> GetRepairsByTechnicianId(TechnicianView t)
 {
     return(workshopClient.GetRepairsByTechnicianId(t));
 }