Пример #1
0
        public dynamic Insert(BranchOffice model)
        {
            try
            {
                if (!AuthenticationModel.IsAllowed("Create", Core.Constants.Constant.MenuName.BranchOffice, Core.Constants.Constant.MenuGroupName.Setting))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Add record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                model = _branchOfficeService.CreateObject(model, _companyInfoService);
            }
            catch (Exception ex)
            {
                LOG.Error("Insert Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors
            }));
        }
Пример #2
0
        public int DoBranchOffice(OleDbDataReader dr, DbContext db)
        {
            int count = 0;

            while (dr.Read()) // read per record/row from a table/sheet
            {
                BranchOffice obj = new BranchOffice
                {
                    Code = dr.GetString(0),
                    Name = dr.GetString(1),
                };
                if (!_branchOfficeService.CreateObject(obj, _companyInfoService).Errors.Any())
                {
                    count++;
                }
                ;
            }
            return(count);
        }