protected override void Save() { OnPropertyChanged("CurrentFirma"); if (this.CanSave()) { FirmModel transport = CurrentFirma.Clone(); if (Mode == EditMode.Add) { if (context.Save <FirmModel>(transport, true)) { base.Save(); CurrentFirma = transport; } else { MessageBox.Show("Грешка"); } } else { if (!context.Save <FirmModel>(transport, false)) { MessageBox.Show("Грешка"); } else { base.Save(); } } } else { MessageBox.Show("Невалидни данни! Моля проверете данните маркирани с червено!"); } }
public FirmViewModel(FirmModel firmaModel) : this() { if (firmaModel == null) { throw new NullReferenceException("firmamodel"); } this._CurrentFirma = firmaModel; }
protected override void Add() { base.Add(); //FirmModel model = CurrentFirma.Clone(); FirmModel model = new FirmModel(); _AllFirms.Add(model); CurrentFirma = model; }
private async Task CreateFirm() { List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("Title", Title) }; if (FieldValidation.ValidateFields(values)) { CanSaveFirm = false; try { FirmModel firmData = new FirmModel() { Name = Title, }; HttpResponseMessage result = null; if (isUpdate) { firmData.ID = ID; firmData.CreatedBy = SelectedFirm.CreatedBy; result = await apiHelper.PutFirm(ParentLayout.LoggedInUser.Token, firmData).ConfigureAwait(false); } else { firmData.CreatedBy = ParentLayout.LoggedInUser.Name; result = await apiHelper.PostFirm(ParentLayout.LoggedInUser.Token, firmData).ConfigureAwait(false); } if (result.IsSuccessStatusCode) { MessageBox.Show($"Firm Saved Successfully", "Success", MessageBoxButton.OK, MessageBoxImage.Information); await GetFirms(); ClearFields(); IsUpdate = false; } else { MessageBox.Show("Error in saving Firm", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } CanSaveFirm = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); CanSaveFirm = true; } } }
public FirmViewModel() : base() { _AllFirms = new ObservableCollection <FirmModel>(context.GetAllFirma()); _Mode = EditMode.View; _Cities = new ObservableCollection <City>(context.GetAllCity()); _Cities2 = new ObservableCollection <City>(context.GetAllCity()); _Countries = new ObservableCollection <Country>(context.GetAllCountry()); if (_AllFirms.Count > 0) { CurrentFirma = _AllFirms.Last(); } else { CurrentFirma = new FirmModel(); } }
public async Task <HttpResponseMessage> PostFirm(string token, FirmModel firmData) { try { httpClient.DefaultRequestHeaders.Clear(); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Add("Authorization", $"bearer {token}"); using (HttpResponseMessage response = await httpClient.PostAsJsonAsync("/api/Firm", firmData)) { return(response); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static void FirmaData(FirmModel firma) { StringBuilder sb = new StringBuilder(); var path = AppDomain.CurrentDomain.BaseDirectory + "FIRMADATA.TXT"; sb.AppendLine(string.Format("Данни за Фирма {0}", firma.Name)); sb.AppendLine();//1 sb.AppendFormat("Име {0}", firma.Name); sb.AppendLine(); sb.AppendFormat("Булстат {0}", firma.Bulstad); sb.AppendLine(); sb.AppendFormat("ЗДДС {0}", firma.DDSnum); sb.AppendLine(); sb.AppendFormat("Телефон {0}", firma.Telefon); sb.AppendLine(); sb.AppendFormat("Град {0} Пощенски код:{1}", firma.CityName, firma.Zip); sb.AppendLine(); sb.AppendFormat("Държава {0}", firma.ContryName); sb.AppendLine(); sb.AppendFormat("Адрес {0}", firma.Address); sb.AppendLine(); sb.AppendFormat("Собственик {0}", firma.NameBoss); sb.AppendLine(); sb.AppendLine("Данни за преставляващия"); sb.AppendFormat(" Преставляващ {0}", firma.Presentor); sb.AppendLine(); sb.AppendFormat(" Име: {0,-20} Презиме: {1,-20} Фамилия: {2,-20}", firma.FirstName, firma.SurName, firma.LastName); sb.AppendLine(); sb.AppendFormat(" Телефон {0}", firma.Tel); sb.AppendLine(); sb.AppendFormat(" Адрес {0}", firma.Address2); sb.AppendLine(); sb.AppendFormat(" Град {0} Пощенски код:{1}", firma.CityName2, firma.Zip2); sb.AppendLine(); using (StreamWriter sw = new StreamWriter(path, false)) { sw.Write(sb.ToString()); } Process.Start(path); }
public FirmViewModel() : base() { _AllFirms = new ObservableCollection <FirmModelWraper>(); foreach (var item in Context.GetAllFirma()) { _AllFirms.Add(new FirmModelWraper(item)); } _Mode = EditMode.View; _Cities = new ObservableCollection <City>(Context.GetAllCity()); //_Cities2 =new ObservableCollection<City>(Context.GetAllCity()); _Countries = new ObservableCollection <Country>(Context.GetAllCountry()); if (_AllFirms.Count > 0) { CurrentFirma = _AllFirms.Last().CurrentFirma; } else { CurrentFirma = new FirmModel(); } SetCityLookup(); }
protected override void Add() { CurrentFirma = new FirmModel(); base.Add(); }
public FirmModelWraper(FirmModel cFirmModel) { _CurrentFirma = cFirmModel; }
//Mappers were made in order to send data from layer to layer and interract with DataAccessLayer (Model) public static Firm ToObject(this FirmModel entity) { return(new Firm(entity.Name, entity.Sphere, entity.Quantity_of_employee, entity.Market_experience)); }