Exemplo n.º 1
0
        public string AddMobileDevice(string jsonMobileDevice)
        {
            string       error        = "";
            MobileDevice mobileDevice = SerializationHelper.DeserializeFromJsonString <MobileDevice>(jsonMobileDevice);
            var          context      = new KoloAndroidEntities();

            context.MobileDevices.Add(mobileDevice);
            context.SaveChanges();
            KoloWsObject <MobileDevice> koloWs = new KoloWsObject <MobileDevice> (error, mobileDevice);
            var result = SerializationHelper.SerializeToJson(koloWs);

            context.Dispose();
            return(result);
        }
Exemplo n.º 2
0
        public string RevokeMobileDevice(string jsonIdMobileDevice)
        {
            string       error        = "";
            MobileDevice mobileDevice = SerializationHelper.DeserializeFromJsonString <MobileDevice>(jsonIdMobileDevice);
            var          context      = new KoloAndroidEntities();

            context.Configuration.ProxyCreationEnabled = false;
            var tmp = context.MobileDevices.FirstOrDefault(c => c.IdMobileDevice == mobileDevice.IdMobileDevice);

            tmp.isActive = false;
            context.SaveChanges();
            KoloWsObject <MobileDevice> koloWs = new KoloWsObject <MobileDevice>(error, tmp);
            var result = SerializationHelper.SerializeToJson(koloWs);

            context.Dispose();
            return(result);
        }
Exemplo n.º 3
0
        public string UpdateCustomerAccount(string jsonCustomer)
        {
            string       error        = "";
            Customer     customer     = SerializationHelper.DeserializeFromJsonString <Customer>(jsonCustomer);
            var          context      = new KoloAndroidEntities();
            var          tmp          = context.Customers.Include("Person").FirstOrDefault(c => c.IdCustomer == customer.IdCustomer);
            MobileDevice mobileDevice = null;

            if (customer.MobileDevices[0] != null)
            {
                mobileDevice = context.MobileDevices.FirstOrDefault(m => m.IdCustomer == customer.IdCustomer && m.IdMobileDevice == customer.MobileDevices[0].IdMobileDevice);
            }
            CustomerHelper.UpdateCustomerAccount(ref tmp, customer, ref mobileDevice, context, out error);
            context.SaveChanges();
            KoloWsObject <Customer> koloWs = new KoloWsObject <Customer>(error, tmp);
            var result = SerializationHelper.SerializeToJson(koloWs);

            context.Dispose();
            return(result);
        }