Beispiel #1
0
        public Dictionary <Object, dynamic> insertProviderInfo()
        {
            if (String.IsNullOrEmpty(data["value"]))
            {
                return(result(Result.Failed, Result.Empty, null));
            }

            try
            {
                data["entity"] = db.Proveedor.Find(((Proveedor)data["entity"]).IdProveedor);
                InfoProveedor providerInfo = createProviderInformation();

                this.oldContent = String.Empty;
                this.newContent = providerInfo.toString();

                db.InfoProveedor.Add(providerInfo);

                db.SaveChanges();

                return(result(Result.Processed, Result.Inserted, null));
            }
            catch (Exception ex)
            {
                return(result(Result.Failed, "Error al insertar el registro: " + ex.Message, null));
            }
        }
Beispiel #2
0
        public Dictionary <Object, dynamic> insertProvider()
        {
            if (String.IsNullOrEmpty(data["phone"]) ||
                String.IsNullOrEmpty(data["name"]) ||
                String.IsNullOrEmpty(data["provincia"]) ||
                String.IsNullOrEmpty(data["canton"]) ||
                String.IsNullOrEmpty(data["distrito"]) ||
                String.IsNullOrEmpty(data["address"]) ||
                String.IsNullOrEmpty(data["email"]))
            {
                return(result(Result.Failed, Result.Empty, null));
            }


            try
            {
                Proveedor provider = createProvider();
                this.oldContent = "";
                this.newContent = provider.toString();
                db.Proveedor.Add(provider);

                Bitacora userLog = createLog(Log.Insert, Log.User, this.oldContent, this.newContent);

                InfoProveedor info = new InfoProveedor((byte)1, data["email"], DateTime.Now, DateTime.Now, data["user"],
                                                       (byte)data["userDeleted"], provider.IdProveedor, data["userStatus"]);
                info.FechaElimina = null;

                DireccionProveedor dir = new DireccionProveedor(data["provincia"], data["canton"], data["distrito"],
                                                                data["address"], DateTime.Now, DateTime.Now, (byte)0, data["user"],
                                                                provider.IdProveedor, data["userStatus"]);
                dir.FechaElimina = null;

                db.InfoProveedor.Add(info);
                db.DireccionProveedor.Add(dir);
                db.Bitacora.Add(userLog);
                db.SaveChanges();

                return(result(Result.Processed, Result.Inserted, null));
            }
            catch (Exception ex)
            {
                return(result(Result.Failed, "Se ha generado un error: " + ex.Message, null));
            }
        }