示例#1
0
        public new BusinessLayerResult <Product> Insert(Product data)
        {
            Product product = Find(x => x.Imei == data.Imei);
            BusinessLayerResult <Product> res = new BusinessLayerResult <Product>();

            res.Result = data;

            if (product != null)
            {
                res.AddError(ErrorMessageCode.DeviceAlreadyExist, "Cihaz imei numarası kayıtlı.");
            }
            else
            {
                if (base.Insert(res.Result) == 0)
                {
                    res.AddError(ErrorMessageCode.DeviceCouldNotInserted, " Cihaz kayıt edilemedi.");
                }
            }

            return(res);
        }
示例#2
0
        public new BusinessLayerResult <Worker> Update(Worker data)
        {
            Worker db_worker = Find(x => x.Username == data.Username || x.Email == data.Email);
            BusinessLayerResult <Worker> res = new BusinessLayerResult <Worker>();

            res.Result = data;

            if (db_worker != null && db_worker.Id != data.Id) //Başka bir kullanıcının mailini girmiş isem
            {
                if (db_worker.Username == data.Username)
                {
                    res.AddError(ErrorMessageCode.UserNameAlreadyExist, "Kullanıcı Adı Kayıtlı");
                }

                if (db_worker.Email == data.Email)
                {
                    res.AddError(ErrorMessageCode.EmailAlreadyExist, "Bu e-posta adresi kayıtlı");
                }

                return(res);
            }

            res.Result           = Find(x => x.Id == data.Id);
            res.Result.ServiceId = data.ServiceId;
            res.Result.Email     = data.Email;
            res.Result.Name      = data.Name;
            res.Result.Surname   = data.Surname;
            res.Result.Username  = data.Username;
            res.Result.Password  = data.Password;
            res.Result.IsActive  = data.IsActive;
            res.Result.IsAdmin   = data.IsAdmin;
            res.Result.IsManager = data.IsManager;
            if (base.Update(res.Result) == 0)
            {
                res.AddError(ErrorMessageCode.WorkerCouldNotUpdated, "Personel Güncellenemedi");
            }

            return(res);
        }
示例#3
0
        public BusinessLayerResult <Cargo> Update(Cargo data, int?ctrl)
        {
            Cargo db_cargo = Find(x => x.ProductId == data.ProductId);
            BusinessLayerResult <Cargo> res = new BusinessLayerResult <Cargo>();

            res.Result = data;

            if (db_cargo == null)
            {
                res.AddError(ErrorMessageCode.CargoDoesNotExist, "Güncellemek istediğiniz kargo bilgisi bulunamadı");
                return(res);
            }
            else
            {
                res.Result           = Find(x => x.ProductId == data.ProductId);
                res.Result.ProductId = data.ProductId;
                res.Result.Firm      = data.Firm;
                res.Result.TrackerNo = data.TrackerNo;
                res.Result.IsArrived = data.IsArrived;

                if (base.Update(res.Result) == 0)
                {
                    res.AddError(ErrorMessageCode.CargoCouldNotInserted, "Kargo bilgisi güncellenemedi");
                }
                else
                {
                    string siteUri  = ConfigHelper.Get <string>("SiteRootUri");
                    string queryUri = $"{siteUri}/Home/CustomerQuery";
                    string bankUri  = $"{siteUri}/Home/Accounts";
                    string body     = $"Merhaba Değerli Müşterimiz <br><b>{res.Result.Product.Imei}</b> no lu cihazınız için daha önce belirtmiş olduğumuz <b><strong>Kargo</strong> bilgileri konusunda bir hata olduğu saptandı.</b>" +
                                      $"<br><br> <strong>Tarafımızca yapılan hatanın düzeltilmesi sonucu cihaz <b>Kargo bilgisi</b>; Firma:<b> {res.Result.Firm}</b>, Kargo Takip No:<b> {res.Result.TrackerNo}</b></strong> olarak güncellendi." +
                                      $"<br><br> <i>Hatamız için özür diler ve anlayışınız için teşekkür ederiz. </i>";

                    MailHelper.SendMail(body, res.Result.Product.Owner.Email, "Kargo Bilgisi Düzeltme");
                }
            }

            return(res);
        }
示例#4
0
        //private Repository<Customer> repo_customer = new Repository<Customer>();
        //private Repository<Product> repo_product = new Repository<Product>();

        public BusinessLayerResult <Product> RegisterCustomerProduct(RegisterViewModel data)
        {
            //ürün imei  kontrolü
            //kayıt işlemi
            //Aktivasyon e-postası Gönderimi
            Product product = Find(x => x.Imei == data.Imei);

            BusinessLayerResult <Product> res = new BusinessLayerResult <Product>();

            if (product != null)
            {
                res.AddError(ErrorMessageCode.DeviceAlreadyExist, "Bu Cihaz sistemde kayıtlı");
            }
            else
            {
                //ServiceManager sm = new ServiceManager();

                int dbResult = Insert(new Product()
                {
                    Imei     = data.Imei,
                    Problems = data.Problems,
                    //Service=new ServiceManager().GetAllService().Where(x=>data.ServiceId.Contains(x.Id)).FirstOrDefault()
                    //Service=sm.List().Where(x=>x.Id==data.ServiceId).FirstOrDefault(),
                    ServiceId  = data.ServiceId,
                    Warranty   = false,
                    IsRepaired = false,
                    AtService  = false,
                    Owner      = new Customer()
                    {
                        Name             = data.Name,
                        Surname          = data.Surname,
                        Email            = data.Email,
                        Tel              = data.Tel,
                        City             = data.City,
                        Adress           = data.Adress,
                        FormNo           = Guid.NewGuid(),
                        IsActive         = false,
                        ModifiedUserName = "******",
                        CreatedOn        = DateTime.Now,
                        ModifiedOn       = DateTime.Now
                    }
                });
                //Customer customer = repo_customer.Find(x => x.Tel == data.Tel && x.Email == data.Email);
                //customer.Products.Add(product);   //Aşağıdaki kod hata verirse alternatif olarak

                if (dbResult > 0)// Burda hata é!!!!!!!
                {
                    res.Result = Find(x => x.Imei == data.Imei);

                    string siteUri  = ConfigHelper.Get <string>("SiteRootUri");
                    string queryUri = $"{siteUri}/Home/CustomerQuery";
                    string body     = $"Merhaba {res.Result.Owner.Tel} no lu müşterimiz <br><br>Cihaz durum takibinizi <a href='{queryUri}' target='_blank'>adresinden</a> <br><br><b>{res.Result.Owner.FormNo}</b> Takip Numarası ile gerçekleştirebilirsiniz.";

                    MailHelper.SendMail(body, res.Result.Owner.Email, "Cihaz Takip Numarası");
                    //layerResult.Result = repo_customer.Find(x => x.Products.Find(y => y.Imei == data.Imei).Imei == data.Imei);
                    //layerResult.Result = repo_customer.Find(x => x.Products.);
                    //TODO
                    //layerResult.Result.ActivateFormGuid
                }
            }

            return(res);
        }