Пример #1
0
        public virtual void SaveAllRecords()
        {
            Response = new Response("", TypeRespone.OK);
            using (BaseService <dbType, dtoType> dataService = new serviceType())
            {
                if (ListNewRecords.Count != 0)
                {
                    Response = dataService.CreateRange(OutMap(ListNewRecords));
                }

                if (Response.Status == TypeRespone.OK)
                {
                    if (ListChangedRecords.Count != 0)
                    {
                        Response = dataService.UpdateRange(OutMap(ListChangedRecords));
                    }

                    if (Response.Status == TypeRespone.OK)
                    {
                        if (ListDeletedRecords.Count != 0)
                        {
                            Response = dataService.DeleteRange(OutMap(ListDeletedRecords));
                        }
                    }
                }
                if (Response.Status == TypeRespone.OK)
                {
                    Response = dataService.Save();
                    if (Response.Status == TypeRespone.OK)
                    {
                        if (ListChangedRecords.Count > 1)
                        {
                            ListChangedRecords.RemoveRange(1, ListChangedRecords.Count - 1);
                        }
                        ListNewRecords.Clear();
                        ListDeletedRecords.Clear();
                        LoadRecords();
                    }
                }
            }
        }