예제 #1
0
        // [Route("Update/{id:int}")]
        public virtual async Task <HttpResponseMessage> Update(int id, Contact contact)
        {
            var userId = SecurityManager.CurrentUserContext.UserId;

            PersonRule personRule = new PersonRule();
            var        person     = personRule.GetPersonByUserId(Convert.ToInt32(userId));

            //ContactRule contactRule = new ContactRule();
            var item = await Rule.FindAsync(id);

            if (item == null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Exception, data = "" }));
            }



            if (!ModelState.IsValid || id != item.ID)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Exception, data = "" }));
            }


            contact.OrganId = person.ID;

            Rule.Update(contact);

            await Rule.SaveChangesAsync();

            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Successful, data = contact }));
        }
예제 #2
0
        public virtual async Task <HttpResponseMessage> GetNewContactObject()
        {
            var userId = SecurityManager.CurrentUserContext.UserId;

            PersonRule personRule = new PersonRule();
            var        person     = personRule.GetPersonByUserId(Convert.ToInt32(userId));

            string code = await CreateCodeContact(person.ID);

            var contactVM = new ContactVM();

            contactVM.Code          = code;
            contactVM.DetailAccount = new DetailAccount()
            {
                Id   = Convert.ToInt32(code),
                Code = code,
                Node = new Node()
                {
                    FamilyTree = "اشخاص",
                    Id         = Convert.ToInt32(code),
                    Name       = "اشخاص",
                }
            };
            contactVM.RegistrationDate = DateTime.Now;


            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Successful, data = contactVM }));
        }
예제 #3
0
 public FormCliente()
 {
     InitializeComponent();
     //definimos de que clase corresponde cada nombre
     this._personRule = new PersonRule();
     this._ClsCliente = new ClsClienteEntity();
 }
예제 #4
0
        public virtual async Task <HttpResponseMessage> GetAllByOrganId([FromBody] string type)
        {
            var        userId     = SecurityManager.CurrentUserContext.UserId;
            PersonRule personRule = new PersonRule();
            var        person     = personRule.GetPersonByUserId(Convert.ToInt32(userId));

            var list = await Rule.GetAllByOrganIdAsync(Convert.ToInt32(person.ID));

            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Successful, data = list }));
        }
예제 #5
0
        public virtual async Task <HttpResponseMessage> GetContactById([FromBody] int id)
        {
            var userId = SecurityManager.CurrentUserContext.UserId;

            PersonRule personRule = new PersonRule();
            var        person     = personRule.GetPersonByUserId(Convert.ToInt32(userId));

            var item = await Rule.FindAsync(id);

            var contactVM = new ContactVM();

            contactVM.Code          = item.Code;
            contactVM.DetailAccount = new DetailAccount()
            {
                Id   = Convert.ToInt32(item.Code),
                Code = item.Code,
                Node = new Node()
                {
                    FamilyTree = "اشخاص",
                    Id         = Convert.ToInt32(item.Code),
                    Name       = "اشخاص",
                }
            };

            contactVM.Address            = item.Address;
            contactVM.City               = item.City;
            contactVM.Credits            = item.Credits;
            contactVM.EconomicCode       = item.EconomicCode;
            contactVM.Email              = item.Email;
            contactVM.Fax                = item.Fax;
            contactVM.ID                 = item.ID;
            contactVM.IsCustomer         = item.IsCustomer;
            contactVM.IsEmployee         = item.IsEmployee;
            contactVM.IsShareHolder      = item.IsShareHolder;
            contactVM.IsVendor           = item.IsVendor;
            contactVM.Liability          = item.Liability;
            contactVM.Mobile             = item.Mobile;
            contactVM.Name               = item.Name;
            contactVM.NationalCode       = item.NationalCode;
            contactVM.Note               = item.Note;
            contactVM.OrganId            = item.OrganId;
            contactVM.Phone              = item.Phone;
            contactVM.PostalCode         = item.PostalCode;
            contactVM.Rating             = item.Rating;
            contactVM.RegistrationDate   = item.RegistrationDate;
            contactVM.RegistrationNumber = item.RegistrationNumber;
            contactVM.SharePercent       = Convert.ToDecimal(item.SharePercent);
            contactVM.State              = item.State;
            contactVM.Website            = item.Website;
            contactVM.ContactType        = item.ContactType;
            contactVM.FirstName          = item.FirstName;
            contactVM.LastName           = item.LastName;
            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Successful, data = contactVM }));
        }
예제 #6
0
        public virtual async Task <HttpResponseMessage> GetBussinessById([FromBody] int id)
        {
            var userId = SecurityManager.CurrentUserContext.UserId;

            PersonRule personRule = new PersonRule();
            var        person     = personRule.GetPersonByUserId(Convert.ToInt32(userId));

            var item = await Rule.FindAsync(id);


            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Successful, data = item }));
        }
예제 #7
0
    private void WriteEquipmentRule(List <string> descriptionLines, PersonRule rule)
    {
        var currentLanguage = _uiSettingService.CurrentLanguage;

        var sign        = GetDirectionString(rule.Direction);
        var bonusString = GetBonusString(rule.Direction);

        var ruleType        = rule.Type;
        var ruleKey         = ruleType.ToString().ToLowerInvariant();
        var ruleDisplayName = StaticPhrases.GetValue($"rule-{ruleKey}", currentLanguage);

        var ruleLevel            = rule.Level;
        var ruleLevelKey         = ruleLevel.ToString().ToLowerInvariant();
        var ruleLevelDisplayName = StaticPhrases.GetValue($"rule-{ruleLevelKey}", currentLanguage);

        descriptionLines.Add($"{bonusString}: {ruleDisplayName}: {sign}{ruleLevelDisplayName}");
    }
예제 #8
0
        public virtual async Task <HttpResponseMessage> GetCurrentUserAndBusinesses()
        {
            var userId = SecurityManager.CurrentUserContext.UserId;

            PersonRule personRule = new PersonRule();

            var person = personRule.GetPersonByUserId(Convert.ToInt32(userId));

            FinanYearRule finanYearRule = new FinanYearRule();

            var finanYears = await finanYearRule.GetAllByOrganIdAsync(person.ID);

            BussinessSiteRule bussinessSiteRule = new BussinessSiteRule();
            var bussinesses = await bussinessSiteRule.GetAllByOrganIdAsync(person.ID);

            var responseCurrentUserAndBusinesses = new ResponseCurrentUserAndBusinesses();

            responseCurrentUserAndBusinesses.appVersion = "3.1";
            responseCurrentUserAndBusinesses.businesses = new List <Bussiness>();
            responseCurrentUserAndBusinesses.businesses = bussinesses.ToList();

            responseCurrentUserAndBusinesses.businessInfo            = new BusinessInfo();
            responseCurrentUserAndBusinesses.businessInfo.business   = bussinesses.SingleOrDefault();
            responseCurrentUserAndBusinesses.businessInfo.finanYear  = finanYears.Where(x => x.Closed == false).SingleOrDefault();
            responseCurrentUserAndBusinesses.businessInfo.finanYears = finanYears.ToList();

            responseCurrentUserAndBusinesses.showCloseFinanYearAlert = false;
            responseCurrentUserAndBusinesses.todayDate = Utilities.PersianDateUtils.ToPersianDate(DateTime.Now);
            responseCurrentUserAndBusinesses.user      = new Common.User()
            {
                FirstName   = person.Nam,
                Id          = person.ID,
                IsConfirmed = true,
                LastName    = person.NamKhanvadegi,
                Phone       = person.Tel,
                Name        = person.Nam + " " + person.NamKhanvadegi,
            };

            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Successful, data = responseCurrentUserAndBusinesses }));
        }
예제 #9
0
        public virtual async Task <HttpResponseMessage> Post(ContactVM contactVM)
        {
            var userId = SecurityManager.CurrentUserContext.UserId;

            PersonRule personRule = new PersonRule();
            var        person     = personRule.GetPersonByUserId(Convert.ToInt32(userId));

            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Exception, data = "" }));
            }

            var contact = new Contact();

            Mapper.Map(contactVM, contact);

            contact.OrganId = person.ID;
            Rule.Insert(contact);

            await Rule.SaveChangesAsync();

            // گرید آی دی جدید را به این صورت دریافت می‌کند
            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Successful, data = contact }));
        }
예제 #10
0
        private List <SurvivalStatBonus> ProcessRuleAndChangeBonusList(List <SurvivalStatBonus> bonusList, IEquipmentModule equipmentModule, PersonRule rule)
        {
            switch (rule.Type)
            {
            case EquipCommonRuleType.Health:
                BonusToHealth(rule.Level, rule.Direction, ref bonusList);
                break;

            case EquipCommonRuleType.HealthIfNoBody:

                var requirementsCompleted = true;

                for (var slotIndex = 0; slotIndex < equipmentModule.Count(); slotIndex++)
                {
                    if ((equipmentModule.Slots[slotIndex].Types & EquipmentSlotTypes.Body) > 0 &&
                        equipmentModule[slotIndex] != null)
                    {
                        requirementsCompleted = false;
                        break;
                    }
                }

                if (requirementsCompleted)
                {
                    BonusToHealth(rule.Level, rule.Direction, ref bonusList);
                }

                break;

            case EquipCommonRuleType.HungerResistance:
                BonusToDownPass(SurvivalStatType.Satiety, rule.Level, rule.Direction, ref bonusList);
                break;

            case EquipCommonRuleType.ThristResistance:
                BonusToDownPass(SurvivalStatType.Hydration, rule.Level, rule.Direction, ref bonusList);
                break;

            default:
                throw new InvalidOperationException($"Правило {rule.Type} не обрабатывается.");
            }

            return(bonusList);
        }
예제 #11
0
 public FormCompras()
 {
     InitializeComponent();
     this._personRule = new PersonRule();
     this._ClsCompra  = new ClsCompraEntity();
 }
예제 #12
0
        public virtual async Task <HttpResponseMessage> AddContact([FromBody] ContactVM contactVM)
        {
            var userId = SecurityManager.CurrentUserContext.UserId;

            PersonRule personRule = new PersonRule();
            var        person     = personRule.GetPersonByUserId(Convert.ToInt32(userId));

            if (!ModelState.IsValid)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Exception, data = contactVM }));
            }

            var contact = new Contact();

            contact = Utilities.TranslateHelper.TranslateContactVMToContact(contactVM);

            contact.RegistrationDate = DateTime.Now;

            contact.OrganId = person.ID;

            //ContactRule contactRule = new ContactRule();
            if (contact.ID > 0)
            {
                Rule.Update(contact);
            }
            else
            {
                Rule.Insert(contact);

                AccountRule accountRule = new AccountRule();
                var         accounts    = await accountRule.GetAllByOrganIdAsync(person.ID);

                var accountDreaftani = accounts.Where(x => x.ComplteCoding == "1104").SingleOrDefault();

                DomainClasses.Accounting.Account tempAccountDreaftani = new DomainClasses.Accounting.Account();
                tempAccountDreaftani.Coding        = contact.Code;
                tempAccountDreaftani.ComplteCoding = "1104" + contact.Code;
                tempAccountDreaftani.Level         = Enums.AccountType.Tafzeli;
                tempAccountDreaftani.Name          = contact.Name;
                tempAccountDreaftani.OrganId       = person.ID;
                tempAccountDreaftani.ParentId      = accountDreaftani.ID;

                this.BusinessRule.UnitOfWork.RepositoryAsync <DomainClasses.Accounting.Account>().Insert(tempAccountDreaftani);

                var accountPardakhtani = accounts.Where(x => x.ComplteCoding == "2101").SingleOrDefault();

                DomainClasses.Accounting.Account tempAccountPardakhtani = new DomainClasses.Accounting.Account();
                tempAccountPardakhtani.Coding        = contact.Code;
                tempAccountPardakhtani.ComplteCoding = "2101" + contact.Code;
                tempAccountPardakhtani.Level         = Enums.AccountType.Tafzeli;
                tempAccountPardakhtani.Name          = contact.Name;
                tempAccountPardakhtani.OrganId       = person.ID;
                tempAccountPardakhtani.ParentId      = accountPardakhtani.ID;

                this.BusinessRule.UnitOfWork.RepositoryAsync <DomainClasses.Accounting.Account>().Insert(tempAccountPardakhtani);


                var accountAsnadDareaftani = accounts.Where(x => x.ComplteCoding == "1105").SingleOrDefault();

                DomainClasses.Accounting.Account tempAccountAsnadDareaftani = new DomainClasses.Accounting.Account();
                tempAccountAsnadDareaftani.Coding        = contact.Code;
                tempAccountAsnadDareaftani.ComplteCoding = "1105" + contact.Code;
                tempAccountAsnadDareaftani.Level         = Enums.AccountType.Tafzeli;
                tempAccountAsnadDareaftani.Name          = contact.Name;
                tempAccountAsnadDareaftani.OrganId       = person.ID;
                tempAccountAsnadDareaftani.ParentId      = accountAsnadDareaftani.ID;

                this.BusinessRule.UnitOfWork.RepositoryAsync <DomainClasses.Accounting.Account>().Insert(tempAccountAsnadDareaftani);
            }
            await this.BusinessRule.UnitOfWork.SaveChangesAsync();

            contactVM.ID = contact.ID;
            contactVM.RegistrationDate = DateTime.Now;
            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Successful, data = contactVM }));
        }
예제 #13
0
        public virtual async Task <HttpResponseMessage> GetAllByOrganId([FromBody] string type)
        {
            var userId = SecurityManager.CurrentUserContext.UserId;

            PersonRule personRule = new PersonRule();
            var        person     = personRule.GetPersonByUserId(Convert.ToInt32(userId));

            var list = await Rule.GetAllByOrganIdAsync(Convert.ToInt32(person.ID));

            // var list2 = list.Select(x => new { ID = x.ID, Title = x.Name, Code = x.Code }).ToList();

            AccountRule accountRule = new AccountRule();
            var         accounts    = await accountRule.GetAllByOrganIdAsync(person.ID);


            List <ContactVM> contactVMs = new List <ContactVM>();
            var contactVM = new ContactVM();

            var detailAccount = new DomainClasses.Accounting.Account();

            foreach (var item in list)
            {
                switch (type)
                {
                case "debtors":
                {
                    detailAccount = accounts.Where(x => x.ComplteCoding == "1104" + item.Code).SingleOrDefault();
                    break;
                }

                case "payables":
                case "inProgress":
                {
                    detailAccount = accounts.Where(x => x.ComplteCoding == "2102" + item.Code).SingleOrDefault();
                    break;
                }

                case "receivables":
                {
                    detailAccount = accounts.Where(x => x.ComplteCoding == "1105" + item.Code).SingleOrDefault();
                    break;
                }

                case "creditors":
                {
                    detailAccount = accounts.Where(x => x.ComplteCoding == "2101" + item.Code).SingleOrDefault();
                    break;
                }


                default:
                {
                    detailAccount = accounts.Where(x => x.ComplteCoding == "1104" + item.Code).SingleOrDefault();
                    break;
                }
                    // break;
                }

                contactVM = new ContactVM();

                contactVM.Code = item.Code;
                if (detailAccount != null)
                {
                    contactVM.DetailAccount = new DetailAccount()
                    {
                        Id   = detailAccount.ID,
                        Code = detailAccount.Coding,
                        Name = detailAccount.Name,

                        Node = new Node()
                        {
                            FamilyTree = "اشخاص",
                            Id         = Convert.ToInt32(item.Code),
                            Name       = "اشخاص",
                        }
                    };
                }

                contactVM.Address            = item.Address;
                contactVM.City               = item.City;
                contactVM.Credits            = item.Credits;
                contactVM.EconomicCode       = item.EconomicCode;
                contactVM.Email              = item.Email;
                contactVM.Fax                = item.Fax;
                contactVM.ID                 = item.ID;
                contactVM.IsCustomer         = item.IsCustomer;
                contactVM.IsEmployee         = item.IsEmployee;
                contactVM.IsShareHolder      = item.IsShareHolder;
                contactVM.IsVendor           = item.IsVendor;
                contactVM.Liability          = item.Liability;
                contactVM.Mobile             = item.Mobile;
                contactVM.Name               = item.Name;
                contactVM.NationalCode       = item.NationalCode;
                contactVM.Note               = item.Note;
                contactVM.OrganId            = item.OrganId;
                contactVM.Phone              = item.Phone;
                contactVM.PostalCode         = item.PostalCode;
                contactVM.Rating             = item.Rating;
                contactVM.RegistrationDate   = item.RegistrationDate;
                contactVM.RegistrationNumber = item.RegistrationNumber;
                contactVM.SharePercent       = Convert.ToDecimal(item.SharePercent);
                contactVM.State              = item.State;
                contactVM.Website            = item.Website;
                contactVM.FirstName          = item.FirstName;
                contactVM.LastName           = item.LastName;
                contactVMs.Add(contactVM);
            }



            return(Request.CreateResponse(HttpStatusCode.OK, new { resultCode = (int)Enums.ResultCode.Successful, data = contactVMs }));
        }