Exemple #1
0
        public BusinessPartnerOrganizationUnitResponse Create(BusinessPartnerOrganizationUnitViewModel businessPartnerOrganizationUnit)
        {
            BusinessPartnerOrganizationUnitResponse response = new BusinessPartnerOrganizationUnitResponse();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();

                SqliteCommand insertCommand = db.CreateCommand();
                insertCommand.CommandText = SqlCommandInsertPart;

                try
                {
                    insertCommand = AddCreateParameters(insertCommand, businessPartnerOrganizationUnit);
                    insertCommand.ExecuteNonQuery();
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    return(response);
                }
                db.Close();

                response.Success = true;
                return(response);
            }
        }
        public static BusinessPartnerOrganizationUnitViewModel ConvertToBusinessPartnerOrganizationUnitViewModel(this BusinessPartnerOrganizationUnit businessPartnerOrganizationUnit)
        {
            BusinessPartnerOrganizationUnitViewModel businessPartnerOrganizationUnitViewModel = new BusinessPartnerOrganizationUnitViewModel()
            {
                Id         = businessPartnerOrganizationUnit.Id,
                Identifier = businessPartnerOrganizationUnit.Identifier,

                BusinessPartner = businessPartnerOrganizationUnit.BusinessPartner?.ConvertToBusinessPartnerViewModelLite(),

                Code = businessPartnerOrganizationUnit.Code,
                Name = businessPartnerOrganizationUnit.Name,

                Address = businessPartnerOrganizationUnit.Address,

                Country      = businessPartnerOrganizationUnit.Country?.ConvertToCountryViewModelLite(),
                City         = businessPartnerOrganizationUnit.City?.ConvertToCityViewModelLite(),
                Municipality = businessPartnerOrganizationUnit.Municipality?.ConvertToMunicipalityViewModelLite(),

                ContactPerson = businessPartnerOrganizationUnit.ContactPerson,
                Phone         = businessPartnerOrganizationUnit.Phone,
                Mobile        = businessPartnerOrganizationUnit.Mobile,

                IsActive = businessPartnerOrganizationUnit.Active,

                CreatedBy = businessPartnerOrganizationUnit.CreatedBy?.ConvertToUserViewModelLite(),
                Company   = businessPartnerOrganizationUnit.Company?.ConvertToCompanyViewModelLite(),

                UpdatedAt = businessPartnerOrganizationUnit.UpdatedAt,
                CreatedAt = businessPartnerOrganizationUnit.CreatedAt,
            };

            return(businessPartnerOrganizationUnitViewModel);
        }
        public BusinessPartnerOrganizationUnitResponse Create(BusinessPartnerOrganizationUnitViewModel businessPartnerOrganizationUnitViewModel)
        {
            BusinessPartnerOrganizationUnitResponse response = new BusinessPartnerOrganizationUnitResponse();

            try
            {
                response = WpfApiHandler.SendToApi <BusinessPartnerOrganizationUnitViewModel, BusinessPartnerOrganizationUnitResponse>(businessPartnerOrganizationUnitViewModel, "Create");
            }
            catch (Exception ex)
            {
                response.BusinessPartnerOrganizationUnit = new BusinessPartnerOrganizationUnitViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
        public BusinessPartnerOrganizationUnitResponse Delete(Guid identifier)
        {
            BusinessPartnerOrganizationUnitResponse response = new BusinessPartnerOrganizationUnitResponse();

            try
            {
                BusinessPartnerOrganizationUnitViewModel viewModel = new BusinessPartnerOrganizationUnitViewModel();
                viewModel.Identifier = identifier;
                response             = WpfApiHandler.SendToApi <BusinessPartnerOrganizationUnitViewModel, BusinessPartnerOrganizationUnitResponse>(viewModel, "Delete");
            }
            catch (Exception ex)
            {
                response.BusinessPartnerOrganizationUnit = new BusinessPartnerOrganizationUnitViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
Exemple #5
0
        public BusinessPartnerOrganizationUnitResponse Create(BusinessPartnerOrganizationUnitViewModel businessPartnerOrganizationUnitViewModel)
        {
            BusinessPartnerOrganizationUnitResponse response = new BusinessPartnerOrganizationUnitResponse();

            try
            {
                BusinessPartnerOrganizationUnit addedBusinessPartnerOrganizationUnit = unitOfWork.GetBusinessPartnerOrganizationUnitRepository().Create(businessPartnerOrganizationUnitViewModel.ConvertToBusinessPartnerOrganizationUnit());
                unitOfWork.Save();
                response.BusinessPartnerOrganizationUnit = addedBusinessPartnerOrganizationUnit.ConvertToBusinessPartnerOrganizationUnitViewModel();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.BusinessPartnerOrganizationUnit = new BusinessPartnerOrganizationUnitViewModel();
                response.Success = false;
                response.Message = ex.Message;
            }
            return(response);
        }
        public JsonResult Delete([FromBody] BusinessPartnerOrganizationUnitViewModel c)
        {
            BusinessPartnerOrganizationUnitResponse response = new BusinessPartnerOrganizationUnitResponse();

            try
            {
                response = this.businessPartnerOrganizationUnitService.Delete(c.Identifier);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                Console.WriteLine(ex.Message);
            }

            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }
Exemple #7
0
        public BusinessPartnerOrganizationUnitResponse GetBusinessPartnerOrganizationUnit(Guid identifier)
        {
            BusinessPartnerOrganizationUnitResponse  response = new BusinessPartnerOrganizationUnitResponse();
            BusinessPartnerOrganizationUnitViewModel businessPartnerOrganizationUnit = new BusinessPartnerOrganizationUnitViewModel();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM BusinessPartnerOrganizationUnits " +
                        "WHERE Identifier = @Identifier;", db);
                    selectCommand.Parameters.AddWithValue("@Identifier", identifier);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        businessPartnerOrganizationUnit = Read(query);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    response.BusinessPartnerOrganizationUnit = new BusinessPartnerOrganizationUnitViewModel();
                    return(response);
                }
                db.Close();
            }
            response.Success = true;
            response.BusinessPartnerOrganizationUnit = businessPartnerOrganizationUnit;
            return(response);
        }
Exemple #8
0
        private SqliteCommand AddCreateParameters(SqliteCommand insertCommand, BusinessPartnerOrganizationUnitViewModel businessPartnerOrganizationUnit)
        {
            insertCommand.Parameters.AddWithValue("@ServerId", businessPartnerOrganizationUnit.Id);
            insertCommand.Parameters.AddWithValue("@Identifier", businessPartnerOrganizationUnit.Identifier);
            insertCommand.Parameters.AddWithValue("@Code", businessPartnerOrganizationUnit.Code);
            insertCommand.Parameters.AddWithValue("@Name", ((object)businessPartnerOrganizationUnit.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerId", ((object)businessPartnerOrganizationUnit.BusinessPartner.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerIdentifier", ((object)businessPartnerOrganizationUnit.BusinessPartner.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerCode", ((object)businessPartnerOrganizationUnit.BusinessPartner.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerName", ((object)businessPartnerOrganizationUnit.BusinessPartner.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerInternalCode", ((object)businessPartnerOrganizationUnit.BusinessPartner.InternalCode) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@BusinessPartnerNameGer", ((object)businessPartnerOrganizationUnit.BusinessPartner.NameGer) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Address", ((object)businessPartnerOrganizationUnit.Address) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryId", ((object)businessPartnerOrganizationUnit.Country?.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryIdentifier", ((object)businessPartnerOrganizationUnit.Country?.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryCode", ((object)businessPartnerOrganizationUnit.Country?.Mark) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CountryName", ((object)businessPartnerOrganizationUnit.Country?.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CityId", ((object)businessPartnerOrganizationUnit.City?.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CityIdentifier", ((object)businessPartnerOrganizationUnit.City?.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CityCode", ((object)businessPartnerOrganizationUnit.City?.ZipCode) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CityName", ((object)businessPartnerOrganizationUnit.City?.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@MunicipalityId", ((object)businessPartnerOrganizationUnit.Municipality?.Id) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@MunicipalityIdentifier", ((object)businessPartnerOrganizationUnit.Municipality?.Identifier) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@MunicipalityCode", ((object)businessPartnerOrganizationUnit.Municipality?.Code) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@MunicipalityName", ((object)businessPartnerOrganizationUnit.Municipality?.Name) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@ContactPerson", ((object)businessPartnerOrganizationUnit.ContactPerson) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Phone", ((object)businessPartnerOrganizationUnit.Phone) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@Mobile", ((object)businessPartnerOrganizationUnit.Mobile) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@IsSynced", businessPartnerOrganizationUnit.IsSynced);
            insertCommand.Parameters.AddWithValue("@UpdatedAt", ((object)businessPartnerOrganizationUnit.UpdatedAt) ?? DBNull.Value);
            insertCommand.Parameters.AddWithValue("@CreatedById", MainWindow.CurrentUser.Id);
            insertCommand.Parameters.AddWithValue("@CreatedByName", MainWindow.CurrentUser.FirstName + " " + MainWindow.CurrentUser.LastName);
            insertCommand.Parameters.AddWithValue("@CompanyId", MainWindow.CurrentCompany.Id);
            insertCommand.Parameters.AddWithValue("@CompanyName", MainWindow.CurrentCompany.CompanyName);

            return(insertCommand);
        }
Exemple #9
0
        private BusinessPartnerOrganizationUnitViewModel Read(SqliteDataReader query)
        {
            int counter = 0;
            BusinessPartnerOrganizationUnitViewModel dbEntry = new BusinessPartnerOrganizationUnitViewModel();

            dbEntry.Id              = SQLiteHelper.GetInt(query, ref counter);
            dbEntry.Identifier      = SQLiteHelper.GetGuid(query, ref counter);
            dbEntry.Code            = SQLiteHelper.GetString(query, ref counter);
            dbEntry.Name            = SQLiteHelper.GetString(query, ref counter);
            dbEntry.BusinessPartner = SQLiteHelper.GetBusinessPartner(query, ref counter);
            dbEntry.Address         = SQLiteHelper.GetString(query, ref counter);
            dbEntry.Country         = SQLiteHelper.GetCountry(query, ref counter);
            dbEntry.City            = SQLiteHelper.GetCity(query, ref counter);
            dbEntry.Municipality    = SQLiteHelper.GetMunicipality(query, ref counter);
            dbEntry.ContactPerson   = SQLiteHelper.GetString(query, ref counter);
            dbEntry.Phone           = SQLiteHelper.GetString(query, ref counter);
            dbEntry.Mobile          = SQLiteHelper.GetString(query, ref counter);
            dbEntry.IsSynced        = SQLiteHelper.GetBoolean(query, ref counter);
            dbEntry.UpdatedAt       = SQLiteHelper.GetDateTime(query, ref counter);
            dbEntry.CreatedBy       = SQLiteHelper.GetCreatedBy(query, ref counter);
            dbEntry.Company         = SQLiteHelper.GetCompany(query, ref counter);

            return(dbEntry);
        }
        public static BusinessPartnerOrganizationUnitViewModel ConvertToBusinessPartnerOrganizationUnitViewModelLite(this BusinessPartnerOrganizationUnit businessPartnerOrganizationUnit)
        {
            BusinessPartnerOrganizationUnitViewModel businessPartnerOrganizationUnitViewModel = new BusinessPartnerOrganizationUnitViewModel()
            {
                Id         = businessPartnerOrganizationUnit.Id,
                Identifier = businessPartnerOrganizationUnit.Identifier,

                Code = businessPartnerOrganizationUnit.Code,
                Name = businessPartnerOrganizationUnit.Name,

                Address = businessPartnerOrganizationUnit.Address,

                ContactPerson = businessPartnerOrganizationUnit.ContactPerson,
                Phone         = businessPartnerOrganizationUnit.Phone,
                Mobile        = businessPartnerOrganizationUnit.Mobile,

                IsActive = businessPartnerOrganizationUnit.Active,

                UpdatedAt = businessPartnerOrganizationUnit.UpdatedAt,
                CreatedAt = businessPartnerOrganizationUnit.CreatedAt,
            };

            return(businessPartnerOrganizationUnitViewModel);
        }
        public static BusinessPartnerOrganizationUnit ConvertToBusinessPartnerOrganizationUnit(this BusinessPartnerOrganizationUnitViewModel businessPartnerOrganizationUnitViewModel)
        {
            BusinessPartnerOrganizationUnit businessPartnerOrganizationUnit = new BusinessPartnerOrganizationUnit()
            {
                Id         = businessPartnerOrganizationUnitViewModel.Id,
                Identifier = businessPartnerOrganizationUnitViewModel.Identifier,

                BusinessPartnerId = businessPartnerOrganizationUnitViewModel.BusinessPartner?.Id ?? null,

                Code = businessPartnerOrganizationUnitViewModel.Code,
                Name = businessPartnerOrganizationUnitViewModel.Name,

                Address = businessPartnerOrganizationUnitViewModel.Address,

                CountryId      = businessPartnerOrganizationUnitViewModel.Country?.Id ?? null,
                CityId         = businessPartnerOrganizationUnitViewModel.City?.Id ?? null,
                MunicipalityId = businessPartnerOrganizationUnitViewModel.Municipality?.Id ?? null,

                ContactPerson = businessPartnerOrganizationUnitViewModel.ContactPerson,
                Phone         = businessPartnerOrganizationUnitViewModel.Phone,
                Mobile        = businessPartnerOrganizationUnitViewModel.Mobile,

                CreatedById = businessPartnerOrganizationUnitViewModel.CreatedBy?.Id ?? null,
                CompanyId   = businessPartnerOrganizationUnitViewModel.Company?.Id ?? null,

                UpdatedAt = businessPartnerOrganizationUnitViewModel.UpdatedAt,
                CreatedAt = businessPartnerOrganizationUnitViewModel.CreatedAt,
            };

            return(businessPartnerOrganizationUnit);
        }