public override int GetHashCode()
 {
     return(ConsistentGuid.Hash(new object[]
     {
         SomeProperty,
         SomeOtherProperty
     }));
 }
Exemple #2
0
        protected override async Task SaveAsync()
        {
            try
            {
                var typeManifestation = View.TypeManifestation;
                var shortName         = View.ShortName;
                var fullName          = View.FullName;
                var additionally      = View.Additionally;


                if (string.IsNullOrWhiteSpace(shortName))
                {
                    throw new ArgumentNullException(null, "Вы не ввели краткое наименование причины обращения заказчика!");
                }
                if (string.IsNullOrWhiteSpace(typeManifestation))
                {
                    throw new ArgumentNullException(null, "Вы не выбрали тип проявления!");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Reason.Where(r => r.ID == (Guid)Identifier).UpdateAsync(r => new ReasonModel
                        {
                            Type         = typeManifestation,
                            ShortName    = shortName,
                            FullName     = GetNullValue(fullName),
                            Additionally = GetNullValue(additionally)
                        });
                    }
                    else
                    {
                        ReasonModel insertReasonInfo = new ReasonModel
                        {
                            ID           = ConsistentGuid.CreateGuid(),
                            Type         = typeManifestation,
                            ShortName    = shortName,
                            FullName     = GetNullValue(fullName),
                            Additionally = GetNullValue(additionally)
                        };

                        context.Reason.Add(insertReasonInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertReasonInfo.ID;
                    }
                }

                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task SaveAsync()
        {
            try
            {
                if (_numberNomenclature == null)
                {
                    throw new ArgumentNullException("_numberNomenclature", "Вы не выбрали работу!");
                }
                if (_workingHourID == null)
                {
                    throw new ArgumentNullException("_workingHourID", "Вы не выбрали нормочас!");
                }


                var amount     = View.Amount;
                var normOfTime = View.NormOfTime;


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Work.Where(w => w.ID == Identifier).UpdateAsync(w => new WorkModel
                        {
                            ID_workingHour      = (Guid)_workingHourID,
                            Number_nomenclature = (int)_numberNomenclature,
                            Amount     = amount,
                            NormOfTime = normOfTime
                        });
                    }
                    else
                    {
                        WorkModel insertWorkInfo = new WorkModel
                        {
                            ID = ConsistentGuid.CreateGuid(),
                            ID_reasonCustomer   = _reasonCustomerID,
                            ID_workingHour      = (Guid)_workingHourID,
                            Number_nomenclature = (int)_numberNomenclature,
                            Amount     = amount,
                            NormOfTime = normOfTime
                        };

                        context.Work.Add(insertWorkInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertWorkInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
    public void ValueObjects_Of_DifferentTypes_Should_Generate_Different_Guids()
    {
        var obj   = new object();
        var other = new int();

        var guid1 = ConsistentGuid.Generate(obj);
        var guid2 = ConsistentGuid.Generate(other);

        Assert.NotEqual(guid1, guid2);
    }
    public void ValueObjects_With_Different_Values_Should_Generate_Different_Guids()
    {
        var obj   = 123;
        var other = 124;

        var guid1 = ConsistentGuid.Generate(obj);
        var guid2 = ConsistentGuid.Generate(other);

        Assert.NotEqual(guid1, guid2);
    }
    public void ValueObjects_With_Same_Values_Should_Generate_Same_Guids()
    {
        var obj   = 123;
        var other = 123;

        var guid1 = ConsistentGuid.Generate(obj);
        var guid2 = ConsistentGuid.Generate(other);

        Assert.False(ReferenceEquals(obj, other));
        Assert.Equal(guid1, guid2);
    }
    public void Referencewise_Equal_Objects_Should_Generate_Same_Guids()
    {
        var obj  = new object();
        var obj2 = obj;

        var guid1 = ConsistentGuid.Generate(obj);
        var guid2 = ConsistentGuid.Generate(obj2);

        Assert.True(ReferenceEquals(obj, obj2));
        Assert.Equal(guid1, guid2);
    }
    public void ReferenceObjects_With_Different_Values_Should_Generate_Different_Guids()
    {
        var a = 123;
        var b = "asd";

        var obj   = new AReferenceType(a, b);
        var other = new AReferenceType(a + 1, b);

        var guid1 = ConsistentGuid.Generate(obj);
        var guid2 = ConsistentGuid.Generate(other);

        Assert.NotEqual(guid1, guid2);
    }
Exemple #9
0
        protected override async Task SaveAsync()
        {
            try
            {
                if (_numberNomenclature == null)
                {
                    throw new ArgumentNullException(null, "Вы не выбрали материал!");
                }


                var amount = View.Amount;
                var price  = View.Price;


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Material.Where(w => w.ID == (Guid)Identifier).UpdateAsync(w => new MaterialModel
                        {
                            Number_nomenclature = (int)_numberNomenclature,
                            Amount = amount,
                            Price  = price
                        });
                    }
                    else
                    {
                        MaterialModel insertMaterialInfo = new MaterialModel
                        {
                            ID = ConsistentGuid.CreateGuid(),
                            ID_reasonCustomer   = _reasonCustomerID,
                            Number_nomenclature = (int)_numberNomenclature,
                            Amount   = amount,
                            Customer = _customer,
                            Price    = price
                        };

                        context.Material.Add(insertMaterialInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertMaterialInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task SaveAsync()
        {
            try
            {
                if (_reasonID == null)
                {
                    throw new ArgumentNullException(null, "Вы не выбрали причину обращения заказчика!");
                }

                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        Guid id = (Guid)_reasonID;
                        await context.ReasonCustomer.Where(rc => rc.ID == _reasonID).UpdateAsync(rc => new ReasonCustomerModel
                        {
                            ID_reason = id
                        });
                    }
                    else
                    {
                        ReasonCustomerModel insertReasonCustomerInfo = new ReasonCustomerModel
                        {
                            ID        = ConsistentGuid.CreateGuid(),
                            ID_reason = (Guid)_reasonID,
                            Number    = _numberApplication
                        };

                        context.ReasonCustomer.Add(insertReasonCustomerInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertReasonCustomerInfo.ID;

                        _workJournal.ReasonCustomerID             = Identifier;
                        _materialJournal.ReasonCustomerID         = Identifier;
                        _materialCustomerJournal.ReasonCustomerID = Identifier;
                    }
                }
                if (!openView)
                {
                    View.Close();
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Exemple #11
0
        protected override async Task SaveAsync()
        {
            try
            {
                var name = View.NameModel;

                if (_markID == null)
                {
                    throw new ArgumentNullException(null, "Вы не выбрали модель");
                }
                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentNullException(null, "Вы не ввели имя модели");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Model.Where(m => m.ID == Identifier).UpdateAsync(m => new ModelModel
                        {
                            ID_mark = (Guid)_markID,
                            Name    = name
                        });
                    }
                    else
                    {
                        ModelModel insertModelInfo = new ModelModel
                        {
                            ID      = ConsistentGuid.CreateGuid(),
                            ID_mark = (Guid)_markID,
                            Name    = name
                        };

                        context.Model.Add(insertModelInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertModelInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
    public void ReferenceObjects_With_Same_Values_Should_Generate_Same_Guids()
    {
        var a = 123;
        var b = "asd";

        var obj   = new AReferenceType(a, b);
        var other = new AReferenceType(a, b);

        var guid1 = ConsistentGuid.Generate(obj);
        var guid2 = ConsistentGuid.Generate(other);

        Assert.False(ReferenceEquals(obj, other));
        Assert.Equal(obj.GetHashCode(), other.GetHashCode());
        Assert.Equal(guid1, guid2);
    }
Exemple #13
0
        protected override async Task SaveAsync()
        {
            try
            {
                var number = View.Number;
                var date   = View.Date;


                if (string.IsNullOrWhiteSpace(number))
                {
                    throw new ArgumentNullException(null, "Введите номер доверености");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.PowerOfAttorney.Where(pa => pa.ID == (Guid)Identifier).UpdateAsync(pa => new PowerOfAttorneyModel
                        {
                            Number = number,
                            Date   = date
                        });
                    }
                    else
                    {
                        PowerOfAttorneyModel insertPowerOfAttorneyInfo = new PowerOfAttorneyModel
                        {
                            ID               = ConsistentGuid.CreateGuid(),
                            Number           = number,
                            Date             = date,
                            ID_contactPerson = _contactPersonID
                        };

                        context.PowerOfAttorney.Add(insertPowerOfAttorneyInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertPowerOfAttorneyInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task SaveAsync()
        {
            try
            {
                var name  = View.NameWorkingHour;
                var price = View.Price;


                if (string.IsNullOrWhiteSpace(name))
                {
                    throw new ArgumentNullException(null, "Вы не ввели наименование нормочаса!");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.WorkingHour.Where(w => w.ID == Identifier).UpdateAsync(w => new WorkingHourModel
                        {
                            Name  = name,
                            Price = price
                        });
                    }
                    else
                    {
                        WorkingHourModel insertWorkingHourInfo = new WorkingHourModel
                        {
                            ID    = ConsistentGuid.CreateGuid(),
                            Name  = name,
                            Price = price
                        };

                        context.WorkingHour.Add(insertWorkingHourInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertWorkingHourInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task SaveAsync()
        {
            try
            {
                var shortName = View.ShortName;
                var fullName  = View.FullName;


                if (string.IsNullOrWhiteSpace(shortName))
                {
                    throw new ArgumentNullException(null, "Вы не ввели краткое наименование марки автомобиля");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Mark.Where(m => m.ID == (Guid)Identifier).UpdateAsync(m => new MarkModel
                        {
                            ShortName = shortName,
                            FullName  = GetNullValue(fullName)
                        });
                    }
                    else
                    {
                        MarkModel insertMarkInfo = new MarkModel
                        {
                            ID        = ConsistentGuid.CreateGuid(),
                            ShortName = shortName,
                            FullName  = GetNullValue(fullName)
                        };

                        context.Mark.Add(insertMarkInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertMarkInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task SaveAsync()
        {
            try
            {
                var post = View.Post;

                if (string.IsNullOrWhiteSpace(post))
                {
                    throw new ArgumentNullException(null, "Вы не ввели должность сотрудника!");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Post.Where(p => p.ID == (Guid)Identifier).UpdateAsync(p => new PostModel
                        {
                            Name = post
                        });
                    }
                    else
                    {
                        PostModel insertPostInfo = new PostModel
                        {
                            ID   = ConsistentGuid.CreateGuid(),
                            Name = post
                        };

                        context.Post.Add(insertPostInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertPostInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Exemple #17
0
        internal override async Task <object> GetInfo()
        {
            bool exists = false;

            try
            {
                Guid id = Item.ID;
                int  verificationExists = 0;

                using (var context = new DbSSContext())
                {
                    verificationExists = await context.OptionCustomer.Where(oc => oc.ID_option == id && oc.Number == _numberApplication).CountAsync();

                    if (verificationExists > 0)
                    {
                        ShowError("Эти коплектация уже находится у заказчика!");
                        exists = false;
                    }
                    else
                    {
                        context.OptionCustomer.Add(new OptionCustomerModel
                        {
                            ID        = ConsistentGuid.CreateGuid(),
                            ID_option = id,
                            Number    = _numberApplication
                        });

                        await context.SaveChangesAsync();

                        exists = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }

            return(exists);
        }
Exemple #18
0
        private async Task SaveUserAsync(string username, string password, bool administrator)
        {
            try
            {
                using (var context = new DbSSContext())
                {
                    if (_userInfo != null)
                    {
                        await context.User.Where(u => u.ID == _userInfo.ID).UpdateAsync(u => new UserModel
                        {
                            Name          = username,
                            Password      = SHA256.Hash(password),
                            Administrator = administrator
                        });
                    }
                    else
                    {
                        UserModel insertUserInfo = new UserModel
                        {
                            ID            = ConsistentGuid.CreateGuid(),
                            Name          = username,
                            Password      = SHA256.Hash(password),
                            Administrator = administrator,
                            ID_employee   = (Guid)Identifier
                        };

                        context.User.Add(insertUserInfo);

                        await context.SaveChangesAsync();

                        _userInfo = insertUserInfo;
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Exemple #19
0
        protected override async Task SaveAsync()
        {
            try
            {
                var view         = View.View;
                var shortName    = View.ShortName;
                var INN          = View.INN;
                var KPP          = View.KPP;
                var OKPO         = View.OKPO;
                var fullName     = View.FullName;
                var phone        = View.Phone;
                var email        = View.Email;
                var address      = View.Address;
                var additionally = View.Additionally;


                if (string.IsNullOrWhiteSpace(view))
                {
                    throw new ArgumentNullException(null, "Вы не выбрали вид контрагента!");
                }
                if (string.IsNullOrWhiteSpace(shortName))
                {
                    throw new ArgumentNullException(null, "Вы не ввели краткое наименование контрагента!");
                }
                if (!string.IsNullOrWhiteSpace(INN) && (INN.Length != 10 && INN.Length != 12))
                {
                    throw new ArgumentNullException(null, "ИНН должен состоять из 10 или 12 цифр!");
                }
                if (!string.IsNullOrWhiteSpace(KPP) && KPP.Length != 9)
                {
                    throw new ArgumentNullException(null, "ОКПО должен состоять из 10 цифр!");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Contractor.Where(c => c.ID == (Guid)Identifier).UpdateAsync(c => new ContractorModel
                        {
                            View         = view,
                            ShortName    = shortName,
                            FullName     = GetNullValue(fullName),
                            INN          = GetNullValue(INN),
                            KPP          = GetNullValue(KPP),
                            OKPO         = GetNullValue(OKPO),
                            Phone        = GetNullValue(phone),
                            Email        = GetNullValue(email),
                            Address      = GetNullValue(address),
                            Additionally = GetNullValue(additionally)
                        });
                    }
                    else
                    {
                        Guid id = ConsistentGuid.CreateGuid();

                        ContractorModel insertContractorInfo = new ContractorModel
                        {
                            ID           = id,
                            View         = view,
                            ShortName    = shortName,
                            FullName     = GetNullValue(fullName),
                            INN          = GetNullValue(INN),
                            KPP          = GetNullValue(KPP),
                            OKPO         = GetNullValue(OKPO),
                            Phone        = GetNullValue(phone),
                            Email        = GetNullValue(email),
                            Address      = GetNullValue(address),
                            Additionally = GetNullValue(additionally)
                        };

                        context.Contractor.Add(insertContractorInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertContractorInfo.ID;

                        _contactNameJournal.ContractorID = id;
                        _carJournal.ContractorID         = id;
                    }
                }
                if (!openView)
                {
                    View.Close();
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Exemple #20
0
        protected override async Task SaveAsync()
        {
            try
            {
                var FFP           = View.FFP;
                var enterUser     = View.EnterUser;
                var username      = View.Username;
                var password      = View.Password;
                var administrator = View.Administrator;

                if (string.IsNullOrWhiteSpace(FFP))
                {
                    throw new ArgumentNullException(null, "Вы не ввели фамилию, имя и отчество сотрудника!");
                }
                if (_postID == null)
                {
                    throw new ArgumentNullException(null, "Вы не выбрали должность сотрудника!");
                }
                if (enterUser && string.IsNullOrWhiteSpace(username))
                {
                    throw new ArgumentNullException(null, "Вы не ввели имя пользователя!");
                }
                if (enterUser && string.IsNullOrWhiteSpace(password))
                {
                    throw new ArgumentNullException(null, "Вы не ввели пароль сотрудника!");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Employee.Where(e => e.ID == (Guid)Identifier).UpdateAsync(e => new EmployeeModel
                        {
                            FFP     = FFP,
                            ID_post = (Guid)_postID
                        });
                    }
                    else
                    {
                        EmployeeModel insertEmployeeInfo = new EmployeeModel
                        {
                            ID      = ConsistentGuid.CreateGuid(),
                            FFP     = FFP,
                            ID_post = (Guid)_postID
                        };


                        context.Employee.Add(insertEmployeeInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertEmployeeInfo.ID;
                    }
                }

                if (View.EnterUser)
                {
                    await SaveUserAsync(username, password, administrator);
                }

                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
Exemple #21
0
        protected override async Task SaveAsync()
        {
            try
            {
                var VIN           = View.VIN;
                var mileage       = View.Mileage;
                var licensePlate  = View.LicensePlate;
                var numberEngine  = View.NumberEngine;
                var numberChassis = View.NumberChassis;
                var numberBody    = View.NumberBody;
                var year          = View.Year;
                var price         = View.Price;
                var color         = View.Color;


                if (_modelID == null)
                {
                    throw new ArgumentNullException(null, "Вы не выбрали модель автомобиля!");
                }
                if (string.IsNullOrWhiteSpace(VIN))
                {
                    throw new ArgumentNullException(null, "Вы не до конца ввели VIN автомобиля!");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.Car.Where(v => v.ID == (Guid)Identifier).UpdateAsync(v => new CarModel
                        {
                            VIN           = VIN,
                            ID_model      = (Guid)_modelID,
                            Mileage       = mileage,
                            LicensePlate  = GetNullValue(licensePlate),
                            NumberEngine  = GetNullValue(numberEngine),
                            NumberChassis = GetNullValue(numberChassis),
                            NumberBody    = GetNullValue(numberBody),
                            Year          = year,
                            Price         = price,
                            Color         = GetNullValue(color),
                            ID_contractor = _contractorID
                        });
                    }
                    else
                    {
                        CarModel insertCarInfo = new CarModel
                        {
                            ID            = ConsistentGuid.CreateGuid(),
                            VIN           = VIN,
                            ID_model      = (Guid)_modelID,
                            LicensePlate  = GetNullValue(licensePlate),
                            NumberEngine  = GetNullValue(numberEngine),
                            NumberChassis = GetNullValue(numberChassis),
                            NumberBody    = GetNullValue(numberBody),
                            Year          = year,
                            Mileage       = mileage,
                            Price         = price,
                            Color         = GetNullValue(color),
                            ID_contractor = _contractorID
                        };

                        context.Car.Add(insertCarInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertCarInfo.ID;
                    }
                }
                View.Close();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        protected override async Task SaveAsync()
        {
            try
            {
                var FFP          = View.FFP;
                var phone        = View.Phone;
                var email        = View.Email;
                var address      = View.Address;
                var additionally = View.Additionally;


                if (string.IsNullOrWhiteSpace(FFP))
                {
                    throw new ArgumentNullException(null, "Вы не ввели имя контактного лица!");
                }


                using (var context = new DbSSContext())
                {
                    if (Identifier != null)
                    {
                        await context.ContactPerson.Where(cn => cn.ID == (Guid)Identifier).UpdateAsync(cn => new ContactPersonModel
                        {
                            FFP          = FFP,
                            Phone        = GetNullValue(phone),
                            Email        = GetNullValue(email),
                            Address      = GetNullValue(address),
                            Additionally = GetNullValue(additionally)
                        });
                    }
                    else
                    {
                        Guid id = ConsistentGuid.CreateGuid();
                        ContactPersonModel insertContactPersonInfo = new ContactPersonModel
                        {
                            ID            = id,
                            FFP           = FFP,
                            Phone         = GetNullValue(phone),
                            Email         = GetNullValue(email),
                            Address       = GetNullValue(address),
                            Additionally  = GetNullValue(additionally),
                            ID_сontractor = _contractorID
                        };
                        context.ContactPerson.Add(insertContactPersonInfo);

                        await context.SaveChangesAsync();

                        Identifier = insertContactPersonInfo.ID;
                        _powerOfAttorneyJournal.ContactPersonID = id;
                    }
                }
                if (!openView)
                {
                    View.Close();
                }
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }