// GET api/districts
 public IEnumerable<Districts> Get()
 {
     List<Districts> listDistricts = new List<Districts>();
     DataView dvDistricts = DistrictBO.GetDistrictIDForSync();
     foreach (DataRowView drvDistricts in dvDistricts)
     {
         Districts District = new Districts();
         listDistricts.Add(DistrictBO.GetDistrict(Convert.ToInt32(drvDistricts["DistrictID"])));
     }
     return listDistricts;
 }
        // POST api/districts
        public Districts Post(Districts Districts)
        {
            if (Districts.GUID > 0)
            {
                Districts.DistrictID = Districts.GUID;
                Districts.SyncStatus = 1;
                int rowResult = DistrictBO.UpdateDistrict(Districts);                
                //Return Back to The Client               
                return Districts;
            }
            else
            {  
                int rowResult = DistrictBO.InsertDistrict(Districts);
                //Return Back to The Client               
                return Districts;
            }

        }
        public int InsertDistrict(Districts Districts)
        {
            Districts.DistrictID = -1;
            BeginTransaction();

            try
            {
                Districts.DistrictID = Insert(Districts);
                CommitTransaction();
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                Districts.DistrictID = -1;
            }

            return Districts.DistrictID;
        }
        public int UpdateDistrict(Districts Districts)
        {
            int rowsaffected = -1;
            BeginTransaction();
            try
            {
                String[] UpdateProperties = new String[] { "DistrictName", "ZoneID", "DistrictCode", "UpdatedBy", "UpdatedDate", "SyncStatus" };
                rowsaffected = Update(Districts, UpdateProperties);

                CommitTransaction();
            }
            catch (Exception e)
            {
                RollBackTransaction();
                rowsaffected = -1;
            }
            return rowsaffected;

        }
Beispiel #5
0
 public static int UpdateDistrict(Districts Districts)
 {
     return new DistrictsDAO().UpdateDistrict(Districts);
 }
Beispiel #6
0
 public static int InsertDistrict(Districts Districts)
 {
     return new DistrictsDAO().InsertDistrict(Districts);
 }
Beispiel #7
0
 public static Districts GetDistrict(int DistrictID)
 {
     Districts objDistricts = new Districts();
     return (Districts)(new DistrictsDAO().FillDTO(objDistricts, "DistrictID=" + DistrictID));
 }